http://fabiomaulo.blogspot.pt/2011/05/nhibernate-bizarre-audit.html 

On Thursday, June 21, 2012 11:10:52 PM UTC+1, bartp wrote:
>
>
> 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/-/1Hz2B6SeY7YJ.
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