我有以下(简化的)多对多关系:
public class Tag
{
public string Name { get; set; }
public IList<Product> Products { get; set; }
}
public class Product
{
public IList<Tag> Tags { get; set; }
}
以下代码段返回与至少一个标签匹配的所有产品:
var searchTags = new[] {"tag1", "tag3"};
Tag tagAlias = null;
var query = _session.QueryOver<Product>()
.JoinAlias(p => p.Tags, () => tagAlias)
.WhereRestrictionOn(() => tagAlias.Name).IsIn(searchTags)
.List();
如何获得包含所有标签名称的产品的列表?