2010-01-12 35 views
0

所以我有事務和GLAllocations。我想獲取GLAllocation表中沒有相應記錄的所有事務。以下SQL產生我想要的結果。NHibernate:使用Criteria API獲取在其他表中沒有外部記錄的行

select t.* from [Transaction] t 
left join [GLAllocation] gla on gla.TransactionID = t.TransactionId 
where gla.glid is null 

有沒有一種方法可以使用標準API來表示它?或者我需要訴諸於HQL?

回答

0

想通了。

return (List<Transaction>)currentSession 
.CreateCriteria(typeof(Transaction)) 
.CreateCriteria("GLAllocations", JoinType.LeftOuterJoin) 
.Add(Restrictions.IsNull("GL")) 
.List<Transaction>(); 
相關問題