tags:

views:

24

answers:

1

The NHibernate cascade setting in the entity mapping is static. Is there anyway to dynamically disable the "cascade" setting in code to avoid expensive cascade operation in NHiberate during a bulky data transaction? We do not want to use stored procedures or native SQL because we need to have the entity changes captured by NHibernate (audit).

A: 

It is not possible to disable cascading dinamically.

You can use a StatelessSession.

But if you sometimes don't need cascading in a particular relationship, just don't set it. Cascade is a nice feature to have, but it's not required to make things work.

Diego Mijelshon
Thanks for the suggestion, but the StatelessSession bypasses the interceptor which will disable the audit function.
Joe Black