组件集合中的级联项目
我有一个包含集合的组件。如果我将集合标记为反向,我似乎无法让 NHibernate 保留集合中的项目。如果我在集合上没有 Inverse,它们将持续存在,但我会得到一个插入,然后是一个更新语句。
我的映射是:
m => m.Component(x => x.Configuration, c =>
{
c.HasMany(x => x.ObjectiveTitleTemplates)
.Access.ReadOnlyPropertyThroughCamelCaseField(Prefix.Underscore)
.AsSet()
//.Inverse()
.KeyColumns.Add("ObjectiveProcessInstanceId")
.Cascade.AllDeleteOrphan();
});
有没有办法让它工作,将集合标记为反向,从而避免额外的插入?
谢谢!
I have a component which contains a collection. I can't seem to get NHibernate to persist items in the collection if I have the collection marked as Inverse. They will persist if I don't have Inverse on the collection, but I get an insert and then an update statement.
My mapping is :
m => m.Component(x => x.Configuration, c =>
{
c.HasMany(x => x.ObjectiveTitleTemplates)
.Access.ReadOnlyPropertyThroughCamelCaseField(Prefix.Underscore)
.AsSet()
//.Inverse()
.KeyColumns.Add("ObjectiveProcessInstanceId")
.Cascade.AllDeleteOrphan();
});
Is there a way to get it working marking the collection as Inverse and therefore avoiding the extra insert?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将集合映射为逆向是不够的。您必须:
当您使用
Inverse
时,NHibernate 不会保留该端的关系。Mapping the collection as inverse is not enough. You have to:
When you use
Inverse
, NHibernate does not persist the relationship from that side.