nhibernate QueryOver Queries Query with join using JoinAlias


Example

It's possible to use JoinAlias method to join several tables. It's useful when it's needed to specify some property from the joined table in the select statement:

Customer customerAlias = null;
Organization organizationAlias = null;

IList<Customer> customers = session.QueryOver(() => customerAlias)
    .Left.JoinAlias(x => x.Organization, () => organizationAlias)
    .Where(customer => customer.Name == "Customer Name")
    .And(() => customerAlias.Age > 18)
    .AndNot(() => organizationAlias.Name == "Forbidden Organization")
    .List();