Assuming your Product
class has at least Id
property, you may go for something like this.
If there is more than a Id
property, you will have to explicitly select all these properties.
var searchTags = new[] { "tag1", "tag3" };
Tag tagAlias = null;
Product pr = null, resProduct = null;
var products =
session.QueryOver(() => pr)
.JoinAlias(() => pr.Tags, () => tagAlias)
.WhereRestrictionOn(() => tagAlias.Name).IsIn(searchTags)
.SelectList(list => list
.SelectGroup(p => p.Id)
.SelectCount(p => tagAlias.Name))
.Where(Restrictions.Eq(Projections.Count<Product>(p => tagAlias.Name),
searchTags.Length))
.SelectList(list => list
.SelectGroup(p => p.Id).WithAlias(() => resProduct.Id))
.TransformUsing(Transformers.AliasToBean<Product>())
.List();
I bet there is a less complex answer, just can't find it. Hope this will help anyway.