JoinQueryOver与NHibernate的多个表

时间:2011-07-27 12:16:55

标签: nhibernate lambda entities

我无法在NHibernate JoinQueryOver中构建lambda表达式来解决下面的SQL命令:

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

上面SQL命令中的所有表都在具有相同名称(A,B,C)的实体中,内部联接在WHERE子句中。

如何构建NHibernate lambda查询?

谢谢,

罗斯福

1 个答案:

答案 0 :(得分:4)

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[]>();