views:

35

answers:

1

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 to represent this using the criteria API? Or do I need to resort to HQL?

A: 

Figured it out.

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