Re: Delete child entities along with object

29 views
Skip to first unread message

Billy McCafferty

unread,
Jun 6, 2013, 11:15:43 AM6/6/13
to sharp...@googlegroups.com
Hi N,

Thanks for the positive feedback.  There hasn't been much activity on the codebase for one simple reason, there's nothing I care to change.  We're currently using S#arp Lite for a large order workflow management system using stateless .NET ( https://code.google.com/p/stateless/ ).  The system we're developing is a large Finite State Machine with close to 20 sub-state machines.  We've been really happy so far.

Anyway, with respect to your question, you need to override the default cascade behavior (using an NHibernate override class) so that when the Member gets deleted, it'll cascade deletes down the change.  It's the all-delete-orphan that you need.  Here's a snippet from our current project:

    public class EmailMessageOverride : IOverride
    {
        public void Override(ModelMapper mapper) {
            ...

            mapper.Class<EmailMessage>(map => map.Bag(o => o.EmailAttachments, a =>
            {
                a.Cascade(Cascade.All.Include(Cascade.DeleteOrphans));
                a.Inverse(true);
            }));
        }
    }

Hope this helps!
Billy McCafferty


On Sun, Jun 2, 2013 at 5:49 AM, <ni...@customapp.co.za> wrote:
Hi,

I think my question are more nHibernate related, but mind is mush and cannot think.

I got a "Member" entity.
Some of "Member"'s members are a List of other entities (messages, logs, etc)

When deleting a member, I obviously want to delete all those as well (right now SharpLite will tell me the entity cannot be deleted because other objects depends on it)

Thanks in advance,
N

ps:  Build a huge CMS system using SharpLite...won't be using anything else...ever!  Fantastic stuff.

--
You received this message because you are subscribed to the Google Groups "S#arp Lite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sharp-lite+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



Reply all
Reply to author
Forward
0 new messages