NHibernate: Criteria query - Parents property as select criteria.

SUBJECT: Criteria query - Parent's property as select criteria.

Hi, I'm trying to issue a SELECT statement via Criteria query, but can't get it working...

Basically, I have two classes:

Public Class MyChildClass
...
Public Property MyParent As MyParentClass
...
End Property

Public Property ChildProp1 As Int32
...
End Property
...
End Class

Public Class MyParentClass
...
Public Property ParentProp1 As Int32
...
End Property
...
End Class

Now, ...

criteria = BIS_session.CreateCriteria(GetType(MyChildClass))
criteria.Add(Expression.EqExpression.Eq("ChildProp1 ", SomeValue))

OKAY, so far so good. BUT, what do I do to do this...:

criteria.Add(Expression.EqExpression.Eq("MyParent.ParentProp1", SomeValue))

Can you do table joins with "Criteria Queries"? I checked Hibernate Documentation... (http://www.hibernate.org/hib_docs/reference/en/html/querycriteria.html) , wasn't able to locate information I needed.

Thanks in advance.
[1110 byte] By [THY02K] at [2007-11-19 9:42:40]
# 1 Re: NHibernate: Criteria query - Parents property as select criteria.
Hi!

You coud do this with HQL (Hibernate Query Language), for example:

private IList getObjects(long id)
{
return mySession.Find("from MyNamespace.MyClass as MyParentClass where MyParentClass.MyChildObject.MyOtherChildObject.Id = "+ id);
}

this way you can query any child objects...
jorgetadeu at 2007-11-10 3:30:51 >