dragonfly
dragonfly

Reputation: 17773

NHibernate auditing with Event listeners - how to create history object in IPreUpdateEventListener.OnPreUpdate

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 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!

Upvotes: 1

Views: 1172

Answers (1)

Roger
Roger

Reputation: 1950

however I have no idea how to create a Person object fron OldState array and save it.

Have you had a look at NHibernate Envers? It does just that.

If you don't want to use this framework for some reason, take a look at its source code.

Upvotes: 1

Related Questions