NHibernate映射按代码级联全删除孤儿

时间:2015-02-06 14:26:54

标签: nhibernate cascade mapping-by-code

如何在NHibernate中通过代码映射设置cascade到all-delete-orphans?

[Flags]
public enum Cascade
{
    None = 0,
    Persist = 2,
    Refresh = 4,
    Merge = 8,
    Remove = 16,
    Detach = 32,
    ReAttach = 64,
    DeleteOrphans = 128,
    All = 256,
}

我如何结合All& DeleteOrphans?

1 个答案:

答案 0 :(得分:7)

尝试使用:

r.Cascade(Cascade.All | Cascade.DeleteOrphans);

因为Cascade是[Flag] ...可以使用multi:

What does the [Flags] Enum Attribute mean in C#?