IndexAttribute 类

[本页针对的是实体框架版本 6。最新版本以“实体框架”NuGet 包的形式提供。有关实体框架的更多信息,请参见 msdn.com/data/ef。]

表示置于属性 (property) 上的某个属性 (attribute),以指示该属性 (property) 映射到的数据库列具有索引。

继承层次结构

System.Object
  System.Attribute
    System.ComponentModel.DataAnnotations.Schema.IndexAttribute

命名空间:  System.ComponentModel.DataAnnotations.Schema
程序集:  EntityFramework(在 EntityFramework.dll 中)

语法

声明
<AttributeUsageAttribute(AttributeTargets.Property, AllowMultiple := True)> _
<SuppressMessageAttribute("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments")> _
<SuppressMessageAttribute("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes")> _
Public Class IndexAttribute _
    Inherits Attribute
用法
Dim instance As IndexAttribute
[AttributeUsageAttribute(AttributeTargets.Property, AllowMultiple = true)]
[SuppressMessageAttribute("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments")]
[SuppressMessageAttribute("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes")]
public class IndexAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Property, AllowMultiple = true)]
[SuppressMessageAttribute(L"Microsoft.Design", L"CA1019:DefineAccessorsForAttributeArguments")]
[SuppressMessageAttribute(L"Microsoft.Performance", L"CA1813:AvoidUnsealedAttributes")]
public ref class IndexAttribute : public Attribute
[<AttributeUsageAttribute(AttributeTargets.Property, AllowMultiple = true)>]
[<SuppressMessageAttribute("Microsoft.Design", "CA1019:DefineAccessorsForAttributeArguments")>]
[<SuppressMessageAttribute("Microsoft.Performance", "CA1813:AvoidUnsealedAttributes")>]
type IndexAttribute =  
    class 
        inherit Attribute 
    end
public class IndexAttribute extends Attribute

IndexAttribute 类型公开以下成员。

构造函数

  名称 描述
公共方法 IndexAttribute() 为将按约定命名并且没有指定列顺序、群集或唯一性的索引初始化新的 IndexAttribute 实例。
公共方法 IndexAttribute(String) 为具有给定名称并且没有指定列顺序、群集或唯一性的索引初始化新的 IndexAttribute 实例。
公共方法 IndexAttribute(String, Int32) 为具有给定名称和列顺序,但没有指定群集或唯一性的索引初始化新的 IndexAttribute 实例。

顶部

属性

  名称 描述
公共属性 IsClustered 获取或设置一个值以指示索引是否定义群集索引。
公共属性 IsClusteredConfigured 获取或设置 IsClustered 是否已设置为一个值。
公共属性 IsUnique 获取或设置一个值以指示是否定义唯一索引。
公共属性 IsUniqueConfigured 获取或设置 IsUnique 是否已设置为一个值。
公共属性 Name 获取或设置索引名称。
公共属性 Order 获取或设置确定多列索引的列排序的数字。如果没有指定列顺序,它将为 -1。
公共属性 TypeId 为每个对象实例获取或设置不同的 ID,以便类型描述符不会尝试将所有 IndexAttribute 实例组合成单个实例。 (重写 Attribute.TypeId。)

顶部

方法

  名称 描述
公共方法 Equals(Object) 确定此属性是否指定与给定属性相同的名称和配置。 (重写 Attribute.Equals(Object)。)
受保护的方法 Equals(IndexAttribute) 确定此属性是否指定与给定属性相同的名称和配置。
受保护的方法 Finalize (继承自 Object。)
公共方法 GetHashCode 返回此实例的哈希代码。 (重写 Attribute.GetHashCode()。)
公共方法 GetType (继承自 Object。)
公共方法 IsDefaultAttribute (继承自 Attribute。)
公共方法 Match (继承自 Attribute。)
受保护的方法 MemberwiseClone (继承自 Object。)
公共方法 ToString 返回此实例的字符串表示形式。 (重写 Object.ToString()。)

顶部

显式接口实现  

  名称 描述
显式接口实现私有方法 _Attribute.GetIDsOfNames (继承自 Attribute。)
显式接口实现私有方法 _Attribute.GetTypeInfo (继承自 Attribute。)
显式接口实现私有方法 _Attribute.GetTypeInfoCount (继承自 Attribute。)
显式接口实现私有方法 _Attribute.Invoke (继承自 Attribute。)

顶部

备注

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

线程安全

此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。

请参阅

参考

System.ComponentModel.DataAnnotations.Schema 命名空间