IndexAttribute
Indicates that a member or type should be indexed in the database.
Herda de: Attribute
Construtores
public IndexAttribute()
indexAttribute = IndexAttribute()
Initializes a new IndexAttribute.
public IndexAttribute(string[] fieldNames)
indexAttribute = IndexAttribute(fieldNames)
Type-level constructor declaring one whole index (single- or multi-column) over the named columns, in argument order. Use nameof for compile-safe column names — e.g. [Index(nameof(Client), nameof(Deleted), nameof(Topic))]. The index name is auto-generated (IX_{Table}_{col1}_{col2}…) unless Name is set, and no per-column Order is needed — order follows the argument order. This is the preferred way to declare composite indexes and indexes over inherited base columns.
Propriedades
public bool CacheNull { get; set; }
value = indexAttribute.CacheNull
indexAttribute.CacheNull = value
Gets or sets whether null values should be cached for this index.
public string Condition { get; set; }
value = indexAttribute.Condition
indexAttribute.Condition = value
Optional predicate turning this into a partial (filtered) index — emitted as a trailing WHERE on the CREATE INDEX. Column names must be wrapped in braces so they are quoted per dialect, e.g. Condition = "{IdempotencyKey} <> ''" becomes WHERE [IdempotencyKey] <> '' (SQL Server) / WHERE "IdempotencyKey" <> '' (PostgreSQL / SQLite). The chief use is a unique index that must ignore rows carrying the "unset" value of a key (empty string, sentinel), which a plain unique index would wrongly collapse. For a composite index set it on any one participating member. emits an ordinary, non-filtered index.
public string FieldName { get; set; }
value = indexAttribute.FieldName
indexAttribute.FieldName = value
Gets or sets the database field name for the index.
public string[] FieldNames { get; set; }
value = indexAttribute.FieldNames
indexAttribute.FieldNames = value
The ordered set of columns this type-level index spans (set via the String[]) constructor). When it holds more than one column the columns form a single composite index in this order; with one column it is a single-column index. Takes precedence over FieldName when both are set.
public string Name { get; set; }
value = indexAttribute.Name
indexAttribute.Name = value
Optional shared name used to group columns into a composite index. Two or more properties carrying the same Name are emitted as a single multi-column CREATE INDEX; columns are ordered by Order within the index. When left the column gets its own single-column index named IX_{Table}_{Column}.
public int Order { get; set; }
value = indexAttribute.Order
indexAttribute.Order = value
Position of this column inside a composite index (lowest first). Ignored when Name is .