Does anyone know if it is possible to tell if a specific property on an object is dirty (i.e. the property is different to the one stored on the DB) using NHibernate?
The background to this question is that I will have an object with a (relatively) large number of properties on it. I need to be able to pass a parameter (string) to a function that will determine if that specific property has changed during the lifetime of the page.
If I need to I can create a copy of the object and use reflection at the end of the page lifecycle to check the value, but I am reluctant to do this. It would be great if NHibernate could simply tell me if a property was dirty.
Thanks
That is not currently available through the nHibernate (or Hibnernate, AFAIK) API. You could write something like this yourself by storing the state of the objects when they're loaded into session, then compare them.
NOTE: I haven't seen this for myself, but, if you haven't locked into an ORM choice, you should look at Subsonic. A lot of the dirty status is tracked within the objects themselves, and you'd be able to determine if a particular property is dirty.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With