Try creating new session from that in the event:
private static void Save(IAuditLogEntry auditLogEntry, ISession session)
{
session
.GetSession(EntityMode.Poco)
.Save(auditLogEntry);
}notice session.GetSession(...) On Tue, Jan 12, 2010 at 2:50 PM, Henning <[email protected]> wrote: > Hi > > After a few looong days and a lot of searching I thought I'd try to > get some help here. > > On a few of our entities we need to perform an audit and log the dirty/ > changed fields in a separate table. > I've seen that some people here have asked the same question, but no > answer seem to work. > > What I need to do is to add a new row to the table with the following > info: > entity id, > event type > property name > old value > new value > user > > Please note that this is not the regular audit info that Ayende > blogged about, where you insert ModifiedBy, ModifiedDate etc. > > Almost everything works perfectly. I'm able to retrieve the dirty > values, create the audit entity, but the problem is in the saving of > those entities. > I'm using IPreUpdateEventListener and have also tried > IPostUpdateEventListener, but to no avail. Session does not save the > new entities at all, and throws no exception. > The code I'm trying is as follows: > > public bool OnPreUpdate(PreUpdateEvent updateEvent ) > { > var entity = updateEvent.Entity as ApprovedClaim; > if (entity == null) > return false; > > var session = updateEvent.Session; > var history = new EntityHistory > (entity.Id,EventType.Update, "propname", "2", "3", null); > > session.Save(history); > > return false; > } > > If I can't get it to work I seriously have to consider using DB > triggers, but I'd rather use NH's capabilities. > > Anybody have a clue on what's going on here? > > -- > 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]<nhusers%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > > > >--
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.
