EntityTypeBuilder<TEntity>.HasIndex 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
HasIndex(String[], String) |
使用指定的名稱,在指定的屬性上設定索引。 如果指定屬性清單和具有指定名稱的現有索引,則會針對組態傳回現有的索引。 |
HasIndex(Expression<Func<TEntity,Object>>) |
在指定的屬性上設定未命名的索引。 如果指定屬性清單上有現有的索引,則會傳回現有的索引以供組態使用。 |
HasIndex(String[]) |
在指定的屬性上設定未命名的索引。 如果指定屬性清單上有現有的索引,則會傳回現有的索引以供組態使用。 |
HasIndex(Expression<Func<TEntity,Object>>, String) |
使用指定的名稱,在指定的屬性上設定索引。 如果指定屬性清單和具有指定名稱的現有索引,則會針對組態傳回現有的索引。 |
HasIndex(String[], String)
使用指定的名稱,在指定的屬性上設定索引。 如果指定屬性清單和具有指定名稱的現有索引,則會針對組態傳回現有的索引。
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.IndexBuilder<TEntity> HasIndex (string[] propertyNames, string name);
override this.HasIndex : string[] * string -> Microsoft.EntityFrameworkCore.Metadata.Builders.IndexBuilder<'Entity (requires 'Entity : null)>
Public Overridable Function HasIndex (propertyNames As String(), name As String) As IndexBuilder(Of TEntity)
參數
- propertyNames
- String[]
組成索引的屬性名稱。
- name
- String
要指派給索引的名稱。
傳回
可用來設定索引的物件。
適用於
HasIndex(Expression<Func<TEntity,Object>>)
在指定的屬性上設定未命名的索引。 如果指定屬性清單上有現有的索引,則會傳回現有的索引以供組態使用。
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.IndexBuilder HasIndex (System.Linq.Expressions.Expression<Func<TEntity,object>> indexExpression);
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.IndexBuilder<TEntity> HasIndex (System.Linq.Expressions.Expression<Func<TEntity,object>> indexExpression);
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.IndexBuilder<TEntity> HasIndex (System.Linq.Expressions.Expression<Func<TEntity,object?>> indexExpression);
override this.HasIndex : System.Linq.Expressions.Expression<Func<'Entity, obj>> -> Microsoft.EntityFrameworkCore.Metadata.Builders.IndexBuilder
override this.HasIndex : System.Linq.Expressions.Expression<Func<'Entity, obj>> -> Microsoft.EntityFrameworkCore.Metadata.Builders.IndexBuilder<'Entity (requires 'Entity : null)>
Public Overridable Function HasIndex (indexExpression As Expression(Of Func(Of TEntity, Object))) As IndexBuilder
Public Overridable Function HasIndex (indexExpression As Expression(Of Func(Of TEntity, Object))) As IndexBuilder(Of TEntity)
參數
- indexExpression
- Expression<Func<TEntity,Object>>
Lambda 運算式,表示要包含在索引 blog => blog.Url
() 中的屬性 () 。
如果索引是由多個屬性所組成,請指定匿名型別,包括屬性 (post => new { post.Title, post.BlogId }
) 。
傳回
可用來設定索引的物件。
適用於
HasIndex(String[])
在指定的屬性上設定未命名的索引。 如果指定屬性清單上有現有的索引,則會傳回現有的索引以供組態使用。
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.IndexBuilder<TEntity> HasIndex (params string[] propertyNames);
override this.HasIndex : string[] -> Microsoft.EntityFrameworkCore.Metadata.Builders.IndexBuilder<'Entity (requires 'Entity : null)>
Public Overridable Function HasIndex (ParamArray propertyNames As String()) As IndexBuilder(Of TEntity)
參數
- propertyNames
- String[]
組成索引的屬性名稱。
傳回
可用來設定索引的物件。
適用於
HasIndex(Expression<Func<TEntity,Object>>, String)
使用指定的名稱,在指定的屬性上設定索引。 如果指定屬性清單和具有指定名稱的現有索引,則會針對組態傳回現有的索引。
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.IndexBuilder<TEntity> HasIndex (System.Linq.Expressions.Expression<Func<TEntity,object>> indexExpression, string name);
public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.IndexBuilder<TEntity> HasIndex (System.Linq.Expressions.Expression<Func<TEntity,object?>> indexExpression, string name);
override this.HasIndex : System.Linq.Expressions.Expression<Func<'Entity, obj>> * string -> Microsoft.EntityFrameworkCore.Metadata.Builders.IndexBuilder<'Entity (requires 'Entity : null)>
Public Overridable Function HasIndex (indexExpression As Expression(Of Func(Of TEntity, Object)), name As String) As IndexBuilder(Of TEntity)
參數
- indexExpression
- Expression<Func<TEntity,Object>>
Lambda 運算式,表示要包含在索引 blog => blog.Url
() 中的屬性 () 。
如果索引是由多個屬性所組成,請指定匿名型別,包括屬性 (post => new { post.Title, post.BlogId }
) 。
- name
- String
要指派給索引的名稱。
傳回
可用來設定索引的物件。
適用於
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應