The Contains
is a C# function. In SQL we would use the MyProperty IN (Select ...)
. To achieve that with NHibernate, to have the IN clause and the inner select - we can use the DetachedCriteria
:
The documentation: 15.8. Detached queries and subqueries
There are some detailed examples how to use it:
- Detailed how to, and advantages of the inner select (e.g. paging)
- Inner select with group by cluase (e.g. to filter by select Max(id))
NOTE: I would like to provide you with more details even for your solution, some draft.. But the problem is the snippets in the question. To be able to use IN
both parts should have some ID (the 1) ID to selected and 2) the ID to be compared). ResourceGroup
is missing ID, hard to understand how the pairing tables behind are designed.
But at least the DetachedCriteria concept should give you correct direction...