In the domain model, there are a number of entities that have a Status enum with values of either Active or Deleted.
I'm looking for documentation and advice on recommended approaches on how to handle:
When fetching a collection of entities that have a
Statusenum, to exclude those with the value set toDeletedby default (overridable on a case by case basis)When fetching a child collection of entities, by default to exclude those with the value set to
Deletedby default.
In summary, I effectively want to keep all data relating to entities with a Status enum property, but to exclude those that have a value of Deleted for status by default.
Any pointers in the right direction much appreciated.
You can use a feature in nhibernate called a filter.
Example:
Then when you query:
For more: http://ayende.com/blog/3993/nhibernate-filters