共用方式為


ReferenceOwnershipBuilder<TEntity,TRelatedEntity>.HasIndex 方法

定義

在指定的屬性上設定索引。 如果給定的屬性集上有現有的索引,則會傳回現有的索引以進行設定。

public virtual Microsoft.EntityFrameworkCore.Metadata.Builders.IndexBuilder HasIndex (System.Linq.Expressions.Expression<Func<TRelatedEntity,object>> indexExpression);
override this.HasIndex : System.Linq.Expressions.Expression<Func<'RelatedEntity, obj>> -> Microsoft.EntityFrameworkCore.Metadata.Builders.IndexBuilder
Public Overridable Function HasIndex (indexExpression As Expression(Of Func(Of TRelatedEntity, Object))) As IndexBuilder

參數

indexExpression
Expression<Func<TRelatedEntity,Object>>

Lambda 運算式,表示要包含在索引 blog => blog.Url () 之屬性 () 。

如果索引是由多個屬性所組成,請指定匿名型別,包括屬性 (post => new { post.Title, post.BlogId }) 。

傳回

物件,可用來設定索引。

適用於