Вопрос

Is it possible to overload Session.Delete() behavior to not to perform real deleting from DB but update value of int State column to special deleted value? And would be great to restrict then loading of deleted entities by GetAll() method.

Это было полезно?

Решение

This kind of a Delete is called Soft Delete. You can use interceptor to override Session.Delete() and use where on class mapping to define a formula, like:

<class where="State=0" ...>

Gabriel Schenker has an example on nhforge.org: http://nhibernate.info/blog/2008/09/06/soft-deletes.html

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top