I have two classes: Cat
and DomesticCat
, that extends Cat
.
I want to select all Cat
s, but no oneDomesticCat
. How to do it using NHibernate criteria API?
var nonDomesticCats = session.CreateCriteria<Cat>()
.Add(Restrictions.Eq("class", typeof(Cat)))
.List<Cat>();
class
is a pseudo-property that represents the concrete type of entities in a class hierarchy.
It can be used transparently with any inheritance strategy except implicit.