You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
using System;
namespace Apewer.Source{
/// <summary>索引。</summary>
public sealed class TableIndex {
/// <summary>索引名称。</summary>
public string Name { get; }
/// <summary>表。</summary>
public TableAttribute Table { get; }
/// <summary>索引字段。</summary>
public IndexAttribute[] Fields { get; }
/// <summary>创建索引实例。</summary>
/// <exception cref="ArgumentNullException"></exception>
internal TableIndex(string name, TableAttribute table, IndexAttribute[] fields) { if (name.IsEmpty()) throw new ArgumentNullException(nameof(name)); if (table == null) throw new ArgumentNullException(nameof(table)); if (fields == null) throw new ArgumentNullException(nameof(fields));
Name = name; Table = table; Fields = fields; }
/// <summary></summary>
public override string ToString() { var fields = Fields.FindAll(x => x != null && x.Column != null); if (fields.IsEmpty()) return Name;
var array = fields.Map(x => x.Order == Order.Ascend ? x.Column.Field : $"{x.Column.Field} DESC"); return $"{Name} ({array.Join(", ")})"; }
}
}
|