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
- [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
-
-
-
-
-
Use Query syntax to work with elements2m 46s
-
Attribute query1m 27s
-
Select data into a new anonymous type1m 47s
-
Where clause on attribute value1m 53s
-
Where clause with compare2m 11s
-
Aggregate queries2m 1s
-
Choose output order with OrderBy42s
-
Query for empty elements and blank values3m 21s
-
Group by3m 26s
-
Challenge: Create custom string output1m 46s
-
Solution: Create custom string output1m 14s
-
Challenge: Filter results to show elements with no content47s
-
Solution: Filter results to show elements with no content55s
-
Challenge: Filter results to show invalid values1m 39s
-
Solution: Filter results to show invalid values1m 53s
-
-
-