Nhibernate Linq在左连接时为空

时间:2014-03-25 15:26:40

标签: c# linq nhibernate

是否有一种简单的方法可以执行以下Nhibernate Linq语句

var query = from r in myTable.Query<MyTable>()
            where r.Child == null
            select r

上面的linq查询产生类似于

的内容
SELECT MyTable.Id FROM MyTable WHERE MyTable.ChildId is null

它不引用子表并检查左连接是否为空,如下所示

SELECT MyTable.Id FROM MyTable 
      LEFT JOIN ChildTable ON MyTable.ChildId = ChildTable.Id
WHERE ChildTable.Id is null

1 个答案:

答案 0 :(得分:1)

var query = from r in myTable.Query<MyTable>()
        where r.Child.Id == null
        select r