C# – NHibernate, auditing and computed column values

cnetnhibernate

How is possible to set some special column values when update/insert entities via NHibernate without extending domain classes with special properties?

E.g. every table contains audit columns like CreatedBy, CreatedDate, UpdatedBy, UpdatedDate. But I dont want to add these poperties to the domain classes. I want to keep domain modedl Percistence Ignorance factor as high as possible.

Best Answer

You might want to try looking into NHibernate's IUserType.

At the bottom of the following page is an example where ayende removes some encryption logic out of the entity and allows NHibernate to just take care of it.

http://ayende.com/Blog/archive/2008/07/31/Entities-dependencies-best-practices.aspx