我需要帮助将SQL查询转换为lambda表达式。
查询:
SELECT Sum(Total) AS SumOfTotal, CostSubGroup, Min(IsEstimated) AS MinOfIsEstimated,JobPricingCurrencyUnit
FROM tblCostBatchingSummary
GROUP BY CostSubGroup, IsSubTotal, JobPricingCurrencyUnit
HAVING IsSubTotal = False
我能够重现的内容:
var ComputeCost= db.tblCostBatchingSummaries
.GroupBy(x => new { x.CostSubGroup, x.JobPricingCurrencyUnit, x.IsSubtotal })
.Where(m=>m.Key.IsSubtotal==false)
.Select(g => new { CostSubGroup = g.Key.CostSubGroup, CurrencyUnit = g.Key.JobPricingCurrencyUnit, Total = g.Sum(x => x.Total), MinEsitmated= g.Min(x=>x.IsEstimated) })
.ToList();
我目前得到的错误
The specified method 'Boolean Min[tblCostBatchingSummary,Boolean](System.Collections.Generic.IEnumerable`1[Earthwatch.Models.tblCostBatchingSummary], System.Func`2[Earthwatch.Models.tblCostBatchingSummary,System.Boolean])' on the type 'System.Linq.Enumerable' cannot be translated into a LINQ to Entities store expression because no overload matches the passed arguments.