开发者

Fluent NHibernate mapping to create a clustered index with HasMany Component

I have a Fluent NHibernate mapping override that I am using to create a HasMany component. Is there a way to have NH create a clustered index on the FK column in the component table? In my example below I am wanting a clustered index on the ItemDetailFk column. Thanks!

public class ItemDetailMap : IAutoMappingOverride<ItemDetail>
{
    public void Override(AutoMapping<ItemDetail> mapping)
    {
        mapping.HasMany<ItemDetailUDF>(x => x.UserDefinedFields)
            .Table("ItemUDF")
            .KeyColumn("ItemDetailFk")
            .Not.LazyLoad()
            .Fetch.Subselect()
            .Component(udfObj 开发者_运维技巧=>
            {
                udfObj.Map(x => x.UDFSequence);
                udfObj.Map(x => x.String0);
                udfObj.Map(x => x.String1);
                udfObj.Map(x => x.String2);

            });
    }
}


By default the PK is created as the clustered index. For clustered index there is more work, see links in Stefan Steinegger's comment. But there is a way to define an index.

mapping.HasMany<ItemDetailUDF>(x => x.UserDefinedFields)
    .Table("ItemUDF")
    .KeyColumns.Add("ItemDetailFk", c => c.Index("myindex"))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜