2
votes

I can't build the lambda expressions in NHibernate JoinQueryOver that solve the SQL command below:

SELECT 
    A.STATUS,
    B.NUMBER,
    B.OTHER_NUMBER,
    A.Date01,
    A.Date02
FROM 
    B, 
    C, 
    A
WHERE
        A.ID = C.ID
    AND     B.ID = C.ID

All tables in SQL command above are in Entities with same name (A, B, C) and the inner join is in WHERE clause.

How can I build the NHibernate lambda query?

Thanks,

Roosevelt

1

1 Answers

4
votes
A a = null;
B b = null;
var result = session.QueryOver<C>()
    .JoinAlias(c => c.A, () => a)
    .JoinAlias(c => c.B, () => b)
    .Select(c => a.Status, c => b.Number, c => b.Other_Number, c => a.Date01, c => a.Date02 )
    .List<object[]>();