Note that there are some explanatory texts on larger screens.

plurals
  1. POData Auditing in NHibernate using events
    primarykey
    data
    text
    <p>I'm revisiting and re-implementing the code that caused me to ask <a href="https://stackoverflow.com/questions/15917/data-auditing-in-nhibernate-and-sqlserver">this question</a> about data auditing in NHibernate. However this time, I want go with <a href="https://stackoverflow.com/users/729/sean-carpenter">Sean Carpenter</a>'s <a href="https://stackoverflow.com/questions/15917/data-auditing-in-nhibernate-and-sqlserver/142767#142767">suggestion</a> and implement the ISaveOrUpdateEventListener (new in NHibernate 2.x)</p> <p>I want to add a row in a database for each change to each property with the old value and the new so later on in the UI I can say stuff like <i>"User Bob changed Wibble's Property from A to B on 9th March 2009 at 21:04"</i></p> <p>What's the best way to compare the object state to work out which of the object's properties have changed?</p> <p>You can get the loaded state of the object by the following:</p> <pre><code> public void OnSaveOrUpdate(SaveOrUpdateEvent saveOrUpdateEvent) { object[] foo = saveOrUpdateEvent.Entry.LoadedState; } </code></pre> <p>And I suppose I could use reflection to work out which properties have changed, but I've been digging around and there doesn't seem to be a matching set of properties to compare. I would've thought there would a GetChangedProperties() method or something.</p> <p>I could always get the old object from the database as it is and compare it, but that's yet another database hit and would seem heavy handed in this scenario.</p> <p>What's the best direction to take with this?</p> <p>P.S. In case it makes any difference, this is an ASP.NET-MVC / S#arp Architecture project.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload