0

我有像这样的表结构

Product {List<Cost> Costs}

Cost{List<Invoice> Invoices, Product product}

Invoice{bool isIncluded}

需要查询以获取所有具有任何成本但不包含任何发票的产品(isIncluded=false for all)

我试过类似的东西:

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 Any[Invoice](System.Collections.Generic.IEnumerable 1[Trigger.StageGate.Services‌​.BusinessEntities.Invoice], System.Func2[Trigger.StageGate.Services.BusinessEntities.Invoice,System.Boolean‌​])

4

1 回答 1

0

try:

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);
于 2013-03-25T12:27:12.683 回答