I had a similar problem and solved it like this:
This criteria should retrieve a list of distinct category ids out of a supplied list of categories (catIdList) that have been assigned to a product:
Code:
DetachedCriteria categories = DetachedCriteria.For( typeof(Product), pc)
.Add( Expression.EqProperty( "pc.Id", "p.Id" ) )
.CreateCriteria("Categories", "c")
.Add( Expression.In( "c.Id", catIdList));
.SetProjection(Projections.CountDistinct("c.Id"));
Now, you can use this in a subquery. The number of selected categories hast to be less or equal to the "count" returned from the subquery:
Code:
ICriteria products = session.CreateCriteria(typeof(Product),"p")
.Add(Subqueries.Le(catIdList.Count, categories));
My scenario was slightly different and I tried this out of my head, so maybe there're some errors, but the idea should work.