I'm taking advantage of great article:
http://ayende.com/blog/3987/nhibernate-ipreupdateeventlistener-ipreinserteventlistener
and have implemented OnPreInsert exactly like in the example. However, my auditing requirement when updating the entity, is to create a "history" entry in database. Let's say:
- I fetch Person object
I modify
personObj.FirstName = Console.ReadLine();
then I save the entity. Now, in IPreUpdateEventListener.OnPreUpdate I want to change UpdatedAt & UpdatedBy properties of Entity & State (just like in the article), and also I need to add a new record to database that contains old values (FirstName before change).
I saw that PreUpdateEvent contains OldState array, however I have no idea how to create a Person object fron OldState array and save it.
How can I achieve what I need?
Thanks!