Reputation: 12336
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
Upvotes: 1
Views: 497
Reputation: 11
Try not use numbers in the alias name.
var criteria = session.CreateCriteria(typeof(Identity))
.CreateAlias("Location", "Al")
.Add(Restrictions.Eq("Al.Room", "room #1"));
Upvotes: 1
Reputation: 2160
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"));
Upvotes: 3