IndexAttribute 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
當此屬性被放置在屬性上時,表示該屬性所映射的資料庫欄位有索引。
[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
- 屬性
備註
此屬性被 Entity Framework Migrations 用來建立映射資料庫欄位上的索引。 多欄索引是透過在多個屬性中使用相同的索引名稱來建立的。 這些屬性中的資訊會合併,以指定實際的資料庫索引。
建構函式
| 名稱 | Description |
|---|---|
| IndexAttribute() |
建立 IndexAttribute 一個索引實例,依慣例命名,且不指定欄位順序、聚類或唯一性。 |
| IndexAttribute(String, Int32) |
建立 IndexAttribute 一個索引實例,名稱與欄位順序相同,但未指定分群或唯一性。 |
| IndexAttribute(String) |
為索引建立 IndexAttribute 一個實例,名稱相同,且未指定欄位順序、分群或唯一性。 |
屬性
| 名稱 | Description |
|---|---|
| IsClustered |
將此屬性設為 true,以定義叢集索引。 將此屬性設為 false 以定義非叢集索引。 |
| IsClusteredConfigured |
若 IsClustered 已設定為 ,則回傳為真。 |
| IsUnique |
將此屬性設為 true,以定義唯一索引。 將此屬性設為 false 以定義非唯一索引。 |
| IsUniqueConfigured |
若 IsUnique 已設定為 ,則回傳為真。 |
| Name |
索引名稱。 |
| Order |
這個數字將用來決定多欄索引的欄位排序。 若未指定欄位順序,該 -1。 |
| TypeId |
會為每個物件實例回傳不同的 ID,使得型別描述符不會嘗試將所有 IndexAttribute 實例合併成單一實例。 |
方法
| 名稱 | Description |
|---|---|
| Equals(IndexAttribute) |
若此屬性指定與該屬性相同的名稱與設定,則返回為真。 |
| Equals(Object) |
若此屬性指定與該屬性相同的名稱與設定,則返回為真。 |
| GetHashCode() |
當此屬性被放置在屬性上時,表示該屬性所映射的資料庫欄位有索引。 |
| ToString() |
當此屬性被放置在屬性上時,表示該屬性所映射的資料庫欄位有索引。 |