Domanda

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.

È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top