删除的对象将通过 nhibernate 中的级联(从关联中删除删除的对象)重新保存
当我尝试从表中删除记录时,我不断收到此错误。除了删除之外,插入和更新工作正常。
这是我的设置:
Mappings:
HasMany(x => x.Items).AsList().AsBag().LazyLoad().Cascade.AllDeleteOrphan();
GetMethod:
IRepositoryWithTypedId<BOD.Entities.Item, Guid> Rep = RepositoryFinder.For<BOD.Entities.Item, Guid>();
BOD.Entities.Item tag = Rep.Get(new Guid("0A495241-082F-4314-8B79-000A524FC666"));
Rep.Delete(tag);
我也尝试过使用:
Repository().DbContext.CommitTransaction();
Repository().DbContext.CommitChanges();
这两个仍然会导致错误。有人有什么建议吗?
I keep getting this error when trying to delete a record from my table. Insert and Update work fine apart from delete.
Here is my set up:
Mappings:
HasMany(x => x.Items).AsList().AsBag().LazyLoad().Cascade.AllDeleteOrphan();
GetMethod:
IRepositoryWithTypedId<BOD.Entities.Item, Guid> Rep = RepositoryFinder.For<BOD.Entities.Item, Guid>();
BOD.Entities.Item tag = Rep.Get(new Guid("0A495241-082F-4314-8B79-000A524FC666"));
Rep.Delete(tag);
I have also tried using:
Repository().DbContext.CommitTransaction();
Repository().DbContext.CommitChanges();
These two still cause errors. Does anyone have any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是因为
tag
包含在某个集合中,您应该将其从该集合中删除才能真正删除它。否则,当您持久化收集实体时,标签将再次保存。this is because
tag
is contained in some collection, you should remove it from that collection to actually delete it. Otherwise when you persist the collecting entity, the tag will be saved again.