Have you looked at NHibernate event listeners and interceptors?

http://nhforge.org/doc/nh/en/index.html#events

Some example:
http://ayende.com/Blog/archive/2009/04/29/nhibernate-ipreupdateeventlistener-amp-ipreinserteventlistener.aspx

/Oskar


2010/4/12 Wouter <[email protected]>:
> Hi,
>
> We are using (Fluent) NHibernate to store our entities in a database.
> For every change to the database we have to add an entry to a
> [Entity]_History table, where [Entity] is the name of our Entity (also
> the name of or database table for that entity). We thought about using
> a trigger in the database, but due to business requirements this is
> not an option.
>
> A possibe solution would be to put the logic in our code so we do two
> inserts/updates in our database, the first to the [Entity]_History
> table and the second to the [Entity] table. For this we could add an
> extra property to the entity in which we indicate what table should be
> inserted/updated. Would a solution like this be possible? If so, how
> do we create two mappings for the same entity but for two different
> tables based on the value of that extra property?
>
> Or is there another (generic) way to implement this with NHibernate?
>
> Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups 
> "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/nhusers?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en.

Reply via email to