views:

23

answers:

1

I have an application that mass-updated a load of entities based on external data. Some of them will have not changed. NHibernate is clever enough to know whether the entity has changed and whether or not to send an update when I call DbContext.CommitChanges().

But I want to be able to output to screen/log when an entity has been updated.

How do I find out if an update has been executed? How do I hook into Nhibernate change tracking?

+2  A: 

NHibernate has an event system you can hook up to. Here is a blog post that explains what you want to do:

NHibernate 2.0 Events and Listeners

Here is the part of the NHibernate tutorial that explains the event system:

Chapter 11. Interceptors and events

And another one:

Creating an Audit Log using NHibernate Events

gcores