Im having trouble using ICriterion.
I have a DirectoryEntry entity that that a many to one relationship with a Location entity.
I want to return all DirectoryEntrys that have profile property or a relationship with a Location who's description property contains a search term.
Iv tried this:
Code:
ICriterion[] parameters = { Expression.Or(Expression.Like("Profile", search, MatchMode.Anywhere), Expression.Like("Location.Description", search, MatchMode.Anywhere)) };
But got this exception:
Code:
{"could not resolve property: Location.Description of: careers.core.domain.intdir.DirectoryEntry"}
How do i query the Description on the Location?
Mappings:
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="careers.core.domain.intdir.DirectoryEntry,careers.core" lazy="false" table="idInternationalDirectory">
<id name="Id" column="ID" type="Int32" unsaved-value="0">
<generator class="native"/>
</id>
<property column="ClientID" type="Int32" name="Clientid" not-null="true" />
<many-to-one name="Location" class="careers.core.domain.intdir.Location,careers.core" column="HESAID"/>
<property column="Profile" type="String" name="Profile" not-null="true" length="2000" />
<property column="url" type="String" name="Url" not-null="true" length="50" />
<set name="Tows" table="idTowLookup">
<key column="entryID" />
<many-to-many column="TOWID" class="careers.core.domain.intdir.Tow,careers.core" />
</set>
</class>
<query name="DirectoryEntry.Search">from DirectoryEntry de where (de.Client.ClientName = ? or de.Profile = ?) </query>
</hibernate-mapping>
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="careers.core.domain.intdir.Location,careers.core" lazy="false" table="Location">
<id name="HesaId" column="HESA_id" type="Int32" unsaved-value="0">
<generator class="assigned"/>
</id>
<property column="description" type="String" name="Description" length="255" />
</class>
<query name="Location.GetAll">from Location order by Description</query>
<query name="Location.GetAllUsed">select distinct de.Location from DirectoryEntry de</query>
</hibernate-mapping>