NHibernate中的inverse和cascade是什么意思
我正在学习 Fluent Nhibernate,我的问题是:逆
是什么意思?我读到这意味着关系的另一方负责保存,Cascade
也是如此,
有人可以解释一下它们之间有什么区别吗? 请详细解释一下,因为我是NH的新手。
I'm learning Fluent Nhibernate and my question is:
What does Inverse
mean? I read that it means that the other side of the relationship is responsible for the saving, and so does Cascade
,
Can someone please explain what are the differences between them?
Please explain in details because I'm a newbie at NH.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看看这段文字 (链接下来,这里有一个镜像archive.org)上对“inverse”属性进行了详细解释。
Ayende 本人在他的博客中很好地解释了不同的级联选项。
推荐阅读的好书是“NHibernate in Action”,虽然这不是一篇简单的文章,但这将涵盖你的很多问题。
Have a look at this text (link down, here's a mirror on archive.org), the "inverse" attribute is explained in detail.
The different cascade options are well explained by Ayende himself in his blog.
A good and recommended read is "NHibernate in Action", while not an easy text, this will cover a lot of your questions.
我找到了何时需要 Inverse = false 的解释。
如果我想要一个包含“子对象”集合的父对象,并且在子对象中不会有
对父级的引用。
所以你在父级上有很多添加 inverse = false 并且不在子级中添加引用。
I found an explanation when Inverse = false is necessary.
If I want a Parent with collection of "children" and in the child object there won't be
a reference to the parent.
so you do Has many on the parent add inverse = false and not adding the reference in the child.