views:

551

answers:

0

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

for example: in my case i would like to get object and just moment before update/insert db add to that object some additional information (like user id or computer name) by using IInterceptor.In other words i would like to add few columns to DB Table with no specifying new properties in original object's class. Do i have to configure/change/add to my Object.hbm.xml or App.config in that case? The problem is that i can't change my original objects and base classes.So i have to figure out if possible to add information to DB table with no changing of original objects(even no inherit from any base classes)

Example:

Original Object has : FirstName ,LastName,Birthday,Address properties

Customer.hbm.xml has:

My Interceptor class has method:

public bool OnSave(object entity, object id, object[] state, string[] propertyNames, NHibernate.Type.IType[] types)

at that moment or even maybe before save i have to add to the DB Customer table additional 2 columns (Computer Name and User Name for example ) that propertyNames[] and state[] parameters don't have them from the beginning,so that shuld be done on the fly.

MY DB Customer table has all the columns that i have described above.

Thank you.