views:

163

answers:

1

Hi!

I would like to make a query which needs to compare an property's property with some value. For example:

... WHERE Identity.Location.Room = "room #1"

How can I achieve this with criteria api?

Best Regards
Oliver Hanappi

+2  A: 

This will perform a query by joining your tables:

var criteria = session.CreateCriteria(typeof(Identity))
    .CreateAlias("Location", "l")
    .Add(Restrictions.Eq("l.Room", "room #1"));
Nigel