功能NHibernate瀑布 - 哪一方?瀑布、功能、NHibernate

2023-09-04 22:40:44 作者:躲在云朵里

在使用功能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.