I am trying to write the Nhibernate ICriteria for the following.
SELECT *
FROM foo
WHERE
(fooKeyColumn1, fooKeyColumn2) IN (
SELECT barKeyColumn1, barKeyColumn2
FROM bar
WHERE <some conditions>)
If I need to check the IN for one column then I can do it using
Subqueries.PropertyIn(propertyName,detachedCriteria);but having trouble if I want to check the same for multiple properties like given in the above sql example.
Any NHibernate experts can guide me to accomplish this?
I want to map this subquery in my existing module which developed using ICriteria as a key component.
You need custom implementation of
SubqueryExpressionto achieve it:And example of usage: