我有像
这样的表结构Product {List<Cost> Costs}
Cost{List<Invoice> Invoices, Product product}
Invoice{bool isIncluded}
需要查询才能获得所有包含任何发票费用的产品(isIncluded = false)
我尝试过类似的事情:
Product pro= null;
Product p = null;
var costQuery = QueryOver.Of<Cost>()
.JoinAlias(c => c.Product, () => p)
.Where(() => p.Id == pro.Id)
.WhereNot(c=>c.Invoices.Any(i=>i.IsIncluded))
.Select(c => c.Id);
var query = CurrentSession.QueryOver<Product>(() => pro)
.WithSubquery.WhereExists(costQuery);
在查询错误中使用“任何”:
无法识别的方法调用:System.Linq.Enumerable:Boolean 任何[发票](System.Collections.Generic.IEnumerable
1[Trigger.StageGate.Services.BusinessEntities.Invoice], System.Func
2 [Trigger.StageGate.Services.BusinessEntities.Invoice,System.Boolean])
答案 0 :(得分:0)
尝试:
var costQuery = QueryOver.Of<Cost>()
.JoinAlias(c => c.Product, () => p)
.Where(() => p.Id == pro.Id)
.JoinQueryOver<Invoice>(c => c.Invoices)
.WhereNot(i => i.IsIncluded)
.Select(c => c.Id);