NHIbernate QueryOver分离标准和Any子句

Sam*_*l G 5 nhibernate

我在子查询中有以下内容失败:

var subquery = QueryOver.Of<Product>()
                .Where(x => x.ProductCategories.Any(y => y.Categgory == parameter.Category));
Run Code Online (Sandbox Code Playgroud)

我收到Any语句的错误:

Unrecognised method call: System.Linq.Enumerable:Boolean Any
Run Code Online (Sandbox Code Playgroud)

我如何更新QueryOver的上述限制?

Ant*_*ton 6

ProductCategory productCategory = null;
var subquery = QueryOver.Of<Product>()
  .JoinAlias(product => product.ProductCategories, () => productCategory)              
  .Where(() => productCategory.Category.Id == parameter.Category.Id);
Run Code Online (Sandbox Code Playgroud)

什么类别的类别?如果这是一个实体:

productCategory.Category.Id == parameter.Category.Id
Run Code Online (Sandbox Code Playgroud)

如果这是基本属性:

productCategory.Category == parameter.Category
Run Code Online (Sandbox Code Playgroud)

这是多对多的关系吗?(产品和类别)

Category category = null;
var subquery = QueryOver.Of<Product>()
  .JoinAlias(product => product.Category, () => category)            
  .Where(() => category.Id == parameter.Category.Id);
Run Code Online (Sandbox Code Playgroud)