使用 HasMany 组件使用流畅的 NHibernate 映射创建聚集索引
我有一个 Fluent NHibernate 映射覆盖,我用它来创建 HasMany 组件。有没有办法让NH在组件表的FK列上创建聚集索引?在下面的示例中,我想要 ItemDetailFk 列上的聚集索引。谢谢!
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);
});
}
}
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);
});
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认情况下,PK 将创建为聚集索引。对于聚集索引还有更多工作,请参阅 Stefan Steinegger 评论中的链接。但有一种方法可以定义索引。
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.