Share via


EntityTypeBuilder<TEntity>.HasIndex 方法

定義

多載

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

要指派給索引的名稱。

傳回

IndexBuilder<TEntity>

可用來設定索引的物件。

適用於

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 }) 。

傳回

IndexBuilder<TEntity>

可用來設定索引的物件。

適用於

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[]

組成索引的屬性名稱。

傳回

IndexBuilder<TEntity>

可用來設定索引的物件。

適用於

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

要指派給索引的名稱。

傳回

IndexBuilder<TEntity>

可用來設定索引的物件。

適用於