LINQ表达式'Sum()'无法翻译,将在本地进行评估

时间:2019-04-01 23:30:35

标签: c# .net-core entity-framework-core entity-framework-core-2.2

我在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.

我想念什么

0 个答案:

没有答案