GroupBy()
noun
say it: “GROOP BY” /ɡruːp baɪ/
The LINQ method that collects items sharing the same value into groups.
What does GroupBy() do in C#?
GroupBy() — A LINQ operation that gathers items sharing the same key.
class OrderGroups
{
object ByStatus(IEnumerable<Order> orders)
{
return orders.GroupBy(order => order.Status);
}
}
record Order(string Status);
In a sentence
- “GroupBy(p => p.CategoryId) gave me one group per category.”
Level: Freelancer · More C# terms at this level
Updated