NHibernate按代码进行映射(大量)-级联选项 [英] NHibernate mapping by code (Loquacious) - Cascade options
问题描述
我对使用NHibernate按代码映射时的级联枚举选项行为有疑问.
I have a question on Cascade enum options behavior when using NHibernate Mapping By Code.
枚举具有以下选项:
[Flags]
public enum Cascade
{
None = 0,
Persist = 2,
Refresh = 4,
Merge = 8,
Remove = 16,
Detach = 32,
ReAttach = 64,
DeleteOrphans = 128,
All = 256,
}
它们旨在像位标记组合一样使用(据我所知).
They are intended to be used like bit flag combinations (as far as I get it).
我已经查看了NHibernate文档,并在其中定义了以下XML映射的级联选项:生命周期和对象图
I've looked thru NHibernate documentation, and the following cascade options for XML mappings are defined there: Lifecycles and object graphs
有人可以通过代码描述新的Nhibernate映射中的级联选项吗?其中一半是自我描述,另一半则不是.
Can anyone describe cascade options from new Nhibernate mapping by code? Half of them are self describing, other half is not.
推荐答案
来自src\NHibernate\Mapping\ByCode\Impl\CascadeConverter.cs
private static IEnumerable<string> CascadeDefinitions(this Cascade source)
{
if (source.Has(Cascade.All))
{
yield return "all";
}
if (source.Has(Cascade.Persist))
{
yield return "save-update, persist";
}
if (source.Has(Cascade.Refresh))
{
yield return "refresh";
}
if (source.Has(Cascade.Merge))
{
yield return "merge";
}
if (source.Has(Cascade.Remove))
{
yield return "delete";
}
if (source.Has(Cascade.Detach))
{
yield return "evict";
}
if (source.Has(Cascade.ReAttach))
{
yield return "lock";
}
if (source.Has(Cascade.DeleteOrphans))
{
yield return "delete-orphan";
}
}
注意:all
级联除delete-orphan
之外的所有内容.
Note: all
cascades all except of delete-orphan
.
这篇关于NHibernate按代码进行映射(大量)-级联选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!