3.2 Mapping by code - cascade all-delete-orphans

90 views
Skip to first unread message

Asher Newcomer

unread,
Jul 14, 2011, 3:04:06 PM7/14/11
to nhusers
With the new mapping by code methodology, is this the proper way to specify a cascade all-delete-orphans setting? 
mapper.BeforeMapSet += (insp, typ, map) => map.Cascade(Cascade.All | Cascade.DeleteOrphans);
I tried using & instead of |, which seems more natural, but that doesn't produce any result. With the | operator, the above produces:
 cascade="all,delete-orphan"
Which is different from what I'm used to:
 cascade="all-delete-orphan"
But appears to function equivalently.
Thanks!
Asher

Fabio Maulo

unread,
Jul 16, 2011, 12:28:07 PM7/16/11
to nhu...@googlegroups.com
Cascade is a comma separated value.
"all-delete-orphan" is just the backdraw compatibility way to define "all, delete-orphan".
Cascade is a [Flags] enums, to know how it works you can use MSDN documentation.

The Cascade enum has this doc:
/// <summary>
/// Defines behavior of soft-cascade actions.
/// </summary>
/// <remarks>
/// To check the content or to include/exclude values, from cascade, is strongly recommanded the usage of extensions methods defined in <see cref="CascadeExtensions"/>
/// </remarks>
/// <seealso cref="CascadeExtensions.Has"/>
/// <seealso cref="CascadeExtensions.Include"/>
/// <seealso cref="CascadeExtensions.Exclude"/>

and the most "intuitive" (that is a matter of opinions/taste) way to use it is:
map.Cascade(Cascade.All.Include(Cascade.DeleteOrphans));


Reply all
Reply to author
Forward
0 new messages