Answer
GroupBy partitions by a key into IGrouping<TKey,T>. In LINQ-to-Objects it buffers; in EF Core only certain shapes translate to SQL GROUP BY, otherwise it fails or evaluates client-side.
var byCat = products.GroupBy(p => p.Category)
.Select(g => new { g.Key, Total = g.Sum(p => p.Price) });Real-world example Summing sales per region for a dashboard — ensure it translates to SQL for large tables.