I have two classes ProjectData and MasterProjectData
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="ProjectData" table="project">
<key column="projectId" />
<many-to-one name="IMasterProject" class="CCAdminData.MasterProjectData, CCAdminData" column="masterGuid" />
</class>
</hibernate-mapping>
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="MasterProjectData" table="MasterProjects">
<id name="Guid" type="System.Guid" column="guid" unsaved-value="00000000-0000-0000-0000-000000000000">
<generator class="guid" />
</id>
<property name="Name"/>
<bag name="Projects" inverse="true">
<key column="masterGuid" />
<one-to-many class="CCAdminData.ProjectData, CCAdminData" />
</bag>
</class>
</hibernate-mapping>
I would like to use a Criteria to search for ProjectsData(s) but i would like to order by MasterProjectData.Name
So my createCriteria is
ICriteria projectCriteria = Db.Session.CreateCriteria(typeof(ProjectData));
To add the order i have tried
Code:
-projectCriteria.AddOrder(Order.Desc("IMasterProject.Name"));
-projectCriteria.AddOrder(Order.Desc("ProjectData.IMasterProject.Name"));
-projectCriteria.AddOrder(Order.Desc("$this.IMasterProject.Name"));
which all give a NullReferenceException on line 1544 of normalizedentitypersister
Does anyone know how to do this?
The reason i want to use a criteria instead of just writing a query is that i would like to use the SetFirstResult and SetMaxResults of the criteria.
Neither of which works