语言

IndexAttribute 类

定义

当此属性放置在属性上时,它指示属性映射到的数据库列具有索引。

[System.AttributeUsage(System.AttributeTargets.Property, AllowMultiple=true)]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments")]
public class IndexAttribute : Attribute
type IndexAttribute = class
    inherit Attribute
Public Class IndexAttribute
Inherits Attribute
继承
IndexAttribute
特性

注解

实体框架迁移使用此属性在映射的数据库列上创建索引。 多列索引是在多个属性中使用同一索引名称创建的。 然后将这些属性中的信息合并在一起,以指定实际的数据库索引。

构造函数

名称 说明
IndexAttribute()

为按约定命名的索引创建实例 IndexAttribute ,并且未指定列顺序、聚类分析或唯一性。

IndexAttribute(String, Int32)

为具有给定名称和列顺序的索引创建实例 IndexAttribute ,但未指定聚集或唯一性。

IndexAttribute(String)

为具有给定名称的索引创建实例 IndexAttribute ,并且没有指定列顺序、聚类分析或唯一性。

属性

名称 说明
IsClustered

将此属性设置为 true 以定义聚集索引。 将此属性设置为 false 以定义非聚集索引。

IsClusteredConfigured

如果 IsClustered 已设置为值,则返回 true。

IsUnique

将此属性设置为 true 以定义唯一索引。 将此属性设置为 false 以定义非唯一索引。

IsUniqueConfigured

如果 IsUnique 已设置为值,则返回 true。

Name

索引名称。

Order

一个数字,用于确定多列索引的列排序。 如果未指定列顺序,则会 -1。

TypeId

为每个对象实例返回不同的 ID,以便类型描述符不会尝试将所有 IndexAttribute 实例合并到单个实例中。

方法

名称 说明
Equals(IndexAttribute)

如果此属性指定与给定属性相同的名称和配置,则返回 true。

Equals(Object)

如果此属性指定与给定属性相同的名称和配置,则返回 true。

GetHashCode()

当此属性放置在属性上时,它指示属性映射到的数据库列具有索引。

ToString()

当此属性放置在属性上时,它指示属性映射到的数据库列具有索引。

适用于