Hi will,

I considered using a column like that, which the trigger watches,
however I'm not overly keen on the solution!

Thanks for your reply.


Mark

On Oct 6, 4:06 pm, "Will Shaver" <[EMAIL PROTECTED]> wrote:
> Could you set a "DeleteMe" column and have the triggers watch for that and
> then delete the row? The problem is that once you delete something with NH,
> the entity is no longer persistant, so changes to it are not sent to the db.
>
> On Mon, Oct 6, 2008 at 5:38 AM, Oz <[EMAIL PROTECTED]> wrote:
>
> > Dear NHUsers,
>
> > I read your Gabriel Schenker's soft deletes article (http://
> >www.nhforge.org/blogs/nhibernate/archive/2008/09/06/soft-deletes.aspx)
> > with great interest and it was very useful!  I have a similar but
> > slightly different requirement which I'm having some trouble
> > implementing, and I wonder if you're able to offer some advice?
>
> > I need to actually do a physical delete from a table, but to update
> > the "ModifiedDate" and "ModifiedBy" fields on the object BEFORE
> > deletion.  The reason I need to do this is that I have a trigger that
> > will fire on deletions, and copy the row to a history table.  I'd like
> > the row in the history table to reference the actual deletion time and
> > have the name of the person who deleted it.
>
> > At the moment, the code I have is as follows, although I have tried
> > various different options.
>
> >        protected override void
> > DeleteEntity(NHibernate.Event.IEventSource session, object entity,
> >            NHibernate.Engine.EntityEntry entityEntry, bool
> > isCascadeDeleteEnabled,
> >            NHibernate.Persister.Entity.IEntityPersister persister,
> > Iesi.Collections.ISet transientEntities)
> >        {
> >            IAuditable auditable = entity as IAuditable;
>
> >            if (auditable != null)
> >            {
> >                auditable.ModifiedDate = DateTime.Now;
> >                auditable.ModifiedBy = "mark";
>
> >                CascadeBeforeDelete(session, persister, auditable,
> > entityEntry, transientEntities);
> >                base.DeleteEntity(session, auditable, entityEntry,
> > isCascadeDeleteEnabled, persister, transientEntities);
> >                CascadeAfterDelete(session, persister, auditable,
> > transientEntities);
> >            }
> >            else
> >            {
> >                base.DeleteEntity(session, entity, entityEntry,
> > isCascadeDeleteEnabled, persister, transientEntities);
> >            }
> >        }
>
> > The code above simply deletes the row, without propagating the update
> > first.  I've also tried doing a session.Update(...) before the
> > CascadeBeforeDelete to no avail.
>
> > I wonder if you could offer any suggestions!  I'm quite new to
> > NHibernate, but appreciate its power and convenience :-)
>
> > Kindest regards,
>
> > Mark
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to