The reference properties causes the problem. I skip them now. Someone a
clue how to audit them?
On Thursday, June 21, 2012 4:25:36 PM UTC+2, bartp wrote:
>
>
> I'm trying todo audit on my entities. The audit is working for
> OnPostUpdate/OnPostInsert but not for OnPostDelete.
>
> Does anyone have a clue for me?
>
> public void OnPostDelete(PostDeleteEvent @event)
> {
> if (@event.Entity is AuditLogEntry)
> {
> return;
> }
>
> var entityFullName = @event.Entity.GetType().FullName;
> var session = @event.Session.GetSession(EntityMode.Poco);
>
> // cannot use this code, {"collection
> [namesspace.Entities.B.Ds] was not processed by flush()"}
> //var sb = new StringBuilder();
> //for (int i = 0; i <= @event.DeletedState.Length - 1; i++)
> //{
> // if (@event.DeletedState[i] != null)
> // {
> // sb.Append(@event.Persister.PropertyNames[i] + ": ");
> // sb.AppendLine(@event.DeletedState[i].ToString());
> // }
> //}
>
> session.Save(new AuditLogEntry
> {
> EntityShortName = @event.Entity.GetType().Name,
> EntityFullName = entityFullName,
> //OldValue = sb.ToString(),
> Username = Environment.UserName,
> EntityId = (long)@event.Id,
> AuditEntryType = "Delete",
> Timestamp = DateTime.Now
> });
>
> session.Flush();
> }
>
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/nhusers/-/WUmTSwzaLgsJ.
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.