So I have Transactions and GLAllocations. I want to get all Transactions that don't have a corresponding record in the GLAllocation table. The following SQL produces the results I want.
select t.* from [Transaction] t
left join [GLAllocation] gla on gla.TransactionID = t.TransactionId
where gla.glid is null
Is there a way t开发者_StackOverflow中文版o represent this using the criteria API? Or do I need to resort to HQL?
Figured it out.
return (List<Transaction>)currentSession
.CreateCriteria(typeof(Transaction))
.CreateCriteria("GLAllocations", JoinType.LeftOuterJoin)
.Add(Restrictions.IsNull("GL"))
.List<Transaction>();
精彩评论