我在Entity Framework Core中有以下查询:
var results = context.Packages.AsNoTracking()
.Select(x => new {
Result = x.Products
.SelectMany(y => y.Definition.Conversions, (Product, Conversion) => new { Product = Product, Conversion = Conversion })
.Where(y => y.Product.DefinitionId == y.Conversion.DefinitionId)
.Select(y => new {
Coefficient = y.Conversion.Coefficient,
Price = y.Product.Price.Value,
})
.GroupBy(y => 1)
.Select(y => new {
Coefficient = y.Sum(z => z.Coefficient),
Price = y.Sum(z => z.Price)
})
}).ToList();
运行此查询时,我收到消息:
The LINQ expression 'Sum()' could not be translated and will be evaluated locally.
我想念什么