Hi,
I have a 2 classes: product and contact
Code:
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<!--Build: with lujan99@usa.net Nhibernate template-->
<class name="Kiwa.Objects.Product,Kiwa.Objects" table="Product" lazy="true">
<id name="Id" column="ID" type="int">
<generator class="native" />
</id>
<property name="Productnr" column="ProductNR" type="string" />
<many-to-one name="Contact1" column="ContactID1" cascade="save-update" />
</class>
</hibernate-mapping>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
<!--Build: with lujan99@usa.net Nhibernate template-->
<class name="Kiwa.Objects.ProductManager,Kiwa.Objects" table="ProductManager" lazy="true">
<id name="Id" column="ID" type="int">
<generator class="native" />
</id>
<property name="Name" column="Name" type="string" not-null="true" />
<property name="Email" column="Email" type="string" />
<property name="Telephone" column="Telephone" type="string" />
<bag name="Contact1Product" inverse="true" lazy="true" cascade="delete">
<key column="ContactID1" />
<one-to-many class="Kiwa.Objects.Product,Kiwa.Objects" />
</bag>
</class>
</hibernate-mapping>
No I want te create a query that gives me all products where the contactName is "Piet".
I Tried the following code:
Code:
Dim session As ISession = SessionHelper.CurrentSession()
session.CreateCriteria(GetType(Product)).SetCacheable(False) _
.Add(Expression.Like("Contact1.Name", "Piet")) _
.List(Of Product)()
This gives me the following error:
could not resolve property: Contact1.Name of: Kiwa.Objects.ProductWhen I do the same statment but with Contact.Id it works fine.
Does someone know what i'm doing wrong?
Thx.