views:

640

answers:

3

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?

Thank you

A: 

You may want to look at this question...

http://stackoverflow.com/questions/97520/nhibernate-auditing-and-computed-column-values

g .
Thank you for you answer.I looked into that before i submit my question,and 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)
A: 

Thank you for you answer.I looked into that before i submit my question,and 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)

Property accessors can do that.
Julian Birch
A: 

There's quite a few ways of doing it, but I think you might this approach useful (even if it doesn't use IInterceptor at all)

http://colourcoding.net/Blog/archive/2008/07/23/denormalize-data-using-nhibernates-property-accessors.aspx

Julian Birch