I want to return 20 items foreach grouping without loading to memory (I shouldn't use AsEnumerable
). I couldn't find the way how:
_context.Products
.Where(predicate)
.Select(t => new ProductViewModel
{
foo = bar
}).OrderBy(t => Guid.NewGuid()).AsNoTracking()
.GroupBy(t => new { CategoryName = t.CategoryName, Id = t.CategoryId })
.Take(20); //??