views:

267

answers:

0

I try to make a soft delete by implementing the DeleteEvent Listener

public class MyDeleteEventListener : DefaultDeleteEventListener

{

protected override void DeleteEntity(IEventSource session, object entity, 

    EntityEntry entityEntry, bool isCascadeDeleteEnabled, 

    IEntityPersister persister, ISet transientEntities)

{

    if (entity is ISoftDeletable)

    {

        var e = (ISoftDeletable)entity;

        e.IsDeleted = true;



        CascadeBeforeDelete(session, persister, entity, entityEntry, transientEntities);

        CascadeAfterDelete(session, persister, entity, transientEntities);

    }

    else

    {

        base.DeleteEntity(session, entity, entityEntry, isCascadeDeleteEnabled,

                          persister, transientEntities);

    }

}

}

(http://blogs.hibernatingrhinos.com/nhibernate/archive/2008/04/08/soft-deletes.aspx)

But it does not soft-delete the entities from one-to-many, may-to-many relationships. Has someone a solution?