From the course: .NET Essentials: LINQ for XML

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Group by

Group by - .NET Tutorial

From the course: .NET Essentials: LINQ for XML

Start my 1-month free trial

Group by

- [Instructor] Another popular query action is to group items into sub groups. In the link world, we use the group and by keywords to do that, this is about the simplest possible grouping syntax we can write. So, we start off on line eight by getting all the card elements, and then I used the group keyword and specify that I want to group the cards. And then I specify a criteria. This becomes a criteria that selects an item into a group. This is called the key selector. So, my key selector is an attribute called team name. And I want the value of that attribute. This is what it looks like. So I see that I get five groups. There's five items are in an I innumerable. And of course that means I can do extra queries on the group, but we're not looking at that yet. And then I see a couple things. Remember I said there's this key selector. That's shown here key. So, this first group is the blue shadows and there is one…

Contents