I think I need to solve this problem with ExistsSubqueryExpression, but since I can't find any information about this, I could use some help.
Say for instance I have some beer coolers, and in each beer cooler I have several different types of beer. I am looking for the coolers that have PBR and Milwaukee's Best in it.
Here is the SQL I need to nhibernate to generate for me...
Code:
select bc.* from BeerCooler bc
where exists
(select 1 from BeerCoolerContents bcc
where bcc.BeerName = 'PBR'
and bcc.Cooler_ID = bc.id)
and exists
(select 1 from BeerCoolerContents bcc
where bcc.BeerName = 'Milwaukee''s Best'
and bcc.Cooler_ID = bc.id)
I know my tables aren't normalized, and there are easier ways to do this query. I just want to see the ExistsSubqueryExpression in action in a Criteria query.
Any help would be greatly appreciated