I'm trying to construct a query in NHibernate to return a list of customers with no orders matching a specific criteria.
My Customer object contains a set of Orders:
<set name="Orders">
<key column="CustomerID" />
<one-to-many class="Order" />
</set>
How do I contruct a query using NHibernate's ICriteria API to get a list of all customers who have no orders? Using native SQL, I am able to represent the query like this:
select * from tblCustomers c where not exists
(select 1 from tblOrders o where c.ID = o.CustomerID)
I have been unable to figure out how to do this using aliases and DetatchedCriteria objects. Any guidance would be appreciated!
Thanks!