I have a problem. I have Persons and Cats. Each Person has some Cats (there is a foreign key in Cats that points to the primary key in Persons). Each Cat has an Age. I want to s
Example taken from this page and adapted (tested with my own classes):
The trick seems to be using an alias.
Person personAlias = null;
IList<Person> persons =
session.QueryOver<Person>(() => personAlias).WithSubquery
.WhereExists(QueryOver.Of<Cat>()
.Where(c => c.Age > 5)
.And(c => c.Owner.Id == personAlias.Id)
.Select(c => c.Owner))
.List<Person>();