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.

我错过了什么

4

0 回答 0