Fluent NHibernate - 映射列表<十进制>到已订购的子表十进制>
我正在重构一个流畅的 nHibernate 映射,但我似乎无法弄清楚这一点。我想将 List
类型的属性重新映射到子表,但如果可能,请使用单个 HasMany
。
现在我们有:Map(x => x.DecimalList);
这给了我们一个很好的类型 varbinary(8000)
在我尝试将其移动到我尝试过的有序子表中:
HasMany(x => x.DecimalList)
.Table("ParentTable_DecimalList")
.KeyColumn("Id")
.Element("Amount")
.KeyColumn("ParentId")
.Cascade.AllDeleteOrphan();
这给了我两列的关系: ParentId< /code> 和
金额
。唯一的问题是我还想在子表上放置一个顺序或主键/ID 列,以确保无论如何都能保留列表的顺序。
有没有办法添加强 int 主键列和/或顺序列,而不将其分解为更复杂的子对象/映射?
I'm refactoring a fluent nHibernate mapping, and I can't seem to figure this one out. I want to remap a property with type List<decimal>
to a child table, but using a single HasMany
if possible.
Right now we have: Map(x => x.DecimalList);
Which gives us a nice type of varbinary(8000)
In my attempts to move this to an ordered child table I've tried:
HasMany(x => x.DecimalList)
.Table("ParentTable_DecimalList")
.KeyColumn("Id")
.Element("Amount")
.KeyColumn("ParentId")
.Cascade.AllDeleteOrphan();
And this gives me the relationship, with two columns: ParentId
and Amount
. The only problem is that I also want to put an Order or Primary Key/ID column on the child table to ensure that we preserve the list's ordering no matter what.
Is there a way to add a strong int Primary Key column and / or an Order column without busting this out to a more complex child object/map?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将其映射为列表
默认情况下,它被映射为包,这不保留顺序。
Map it as a list
By default, it is mapped as a bag, which doesn't preserve the order.