Reputation: 173
We currently employ our own "unit of work" functionality on business objects but are looking to migrate to nHibernate to manage all our database persistence. As nHibernate manages it's own unit of work, is there any way that we can examine 'dirty' objects (when flushed) so that we can write a history log of changes made to the data.
Of course, if the transaction conversation is long, we are only interested in comparing the database value of the property against the new value persisted to the database, any intermediate changes made, do not need to be recorded to the database.
Does anyone have any advice?
Upvotes: 1
Views: 775
Reputation: 5644
Sure, one possible option is to leverage NHibernate listeners such as IPostUpdateEventListener (for tracking updated entities) - please take a look at this nice article which describes essential parts. You can even extend it further to track collections or customize output, etc.
Upvotes: 2