Код: Выделить всё
var products = _db.Products
.Include(p => p.Category).ToList()
.GroupBy(p => new { p.CategoryId })
.Select(g => new
{
CategoryId = g.Key.CategoryId,
Sum = g.Sum(x => x.Price),
Products = g.ToList()
//ProductsTest = g.ToDictionary(x => x.Name, y => y.Price)
});
Когда я пытаюсь запустить это без .ToList(), я получаю следующую ошибку:
Код: Выделить всё
The LINQ expression 'GroupByShaperExpression:
KeySelector: new { CategoryId = p.CategoryId },
ElementSelector:EntityShaperExpression:
EntityType: Product
ValueBufferExpression:
ProjectionBindingExpression: EmptyProjectionMember
IsNullable: False
.ToList()' could not be translated. Either rewrite the query in a form that can be translated, or switch to client evaluation explicitly by inserting a call to 'AsEnumerable', 'AsAsyncEnumerable', 'ToList', or 'ToListAsync'. See https://go.microsoft.com/fwlink/?linkid=2101038 for more information.
Может ли разбиение на страницы в этом случае повысить производительность или нет?
И нужно ли мне использовать для этого другую логику или я что-то упускаю? Спасибо
Подробнее здесь: https://stackoverflow.com/questions/702 ... using-linq
Мобильная версия