I have this NHibernate mapping
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<class name="ParentClass" table="myclass" abstract="true" >
...
<discriminator column="mytype" type="string" />
...
<subclass name="SubClass1" discriminator-value="Type1" />
<subclass name="SubClass2" discriminator-value="Type2" />
</class>
</hibernate-mapping>
So how can I get Projection of discriminator-value like any property in my DAO when I filtering ParentClass objects? Code in DAO:
...
using (ISession session = NHibernateSession)
{
ICriteria criteria = session.CreateCriteria<ParentClass>("p")
...
criteria.SetProjection(Projections.ProjectionList()
.Projections.Property("p.Property1")
.Projections.??? // something to get discriminator-value from myclass.mytype column
...
}
...
This should be the way
"p.class"
:17.1.4.1. Alias and property references