功能NHibernate瀑布 - 哪一方? [英] Fluent NHibernate Cascade - Which side?

查看:110
本文介绍了功能NHibernate瀑布 - 哪一方?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用功能NHibernate,我似乎无法找到当您使用的参考一边主场迎战的hasMany侧级联选项的一个很好的解释。

In using Fluent NHibernate, I can't seem to find a good explanation of when you use the cascading option on the References side vs. the HasMany side.

有什么区别(如果有的话)的映射下...

What's the difference (if any) in mapping the following...

References(...).Cascade.All();

VS

HasMany(...).Cascade.All();

我的问题从问题保存父(根)实体时茎。一旦它的保存,我想,以确保所有子对象也将被保留。

My question stems from a problem when saving a parent (root) entity. Once it's saved, I want to insure that all child objects are also persisted.

推荐答案

您把您所节省的一侧级联。

You put the cascade on the side that you are saving.

如果您保存的父母,想级联到孩子,把父级联映射。

If you save the parent and want to cascade to the children, put the cascade mapping on the parent.

这篇关于功能NHibernate瀑布 - 哪一方?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆