1

could you provide some samples for audit loggin using NHibernate (ASP.Net+C# codd, not java code)

RichieHindle
  • 272,464
  • 47
  • 358
  • 399

2 Answers2

5

Event Listeners are better for audit info than Interceptors. Here's a great example from Ayende's blog.

Rohit Agarwal
  • 4,269
  • 3
  • 27
  • 22
  • 1
    One caveat that I discovered when using Ayende's solution: it only works using static updates, not dynamic. This was true up until NH 3.0, not sure about 3.1 and 3.2. This has been documented in a couple of places: http://stackoverflow.com/questions/5087888/ipreupdateeventlistener-and-dynamic-update-true and http://stackoverflow.com/questions/4383420/nhibernate-preupdate-event-listener-not-persisting-changes – Rob Kent Sep 20 '11 at 09:44
1

I've most often seen this done with interceptors. There are plenty of blog postings to be found through Google about implementing interceptors for auditing, like this one.

Stuart Childs
  • 3,295
  • 1
  • 19
  • 11