From the course: .NET Essentials: Working with LINQ
Unlock this course with a free trial
Join today to access over 22,500 courses taught by industry experts.
GroupBy with ElementSelector - .NET Tutorial
From the course: .NET Essentials: Working with LINQ
GroupBy with ElementSelector
- [Instructor] I'm looking at a previous example. This is where I use the group by extension method. And I provided the key to create the group here with the color family. So, remember what happens when I run this? I get 11 items in the sequence, 11 groups in the sequence. And when I look at one of the groups, like here I'm looking at the group that has the key red, I'm seeing there are nine items in that group. And I see all of the properties on that web color type. Now, I sometimes call these columns when I'm using LINQPad, because LINQPad puts them in columns. But, of course, they're properties of the web color class. There are times when you don't want to see all these properties, and we've seen this in some of the other examples we've looked at where we use an anonymous type to project out a new type with just the columns that we want. So, there's a way to do this using the group by extension method. It is called the…
Contents
-
-
-
-
-
-
-
-
-
-
-
The GroupBy method2m 27s
-
GroupBy query expression1m 53s
-
GroupBy with ElementSelector2m 36s
-
GroupBy with ResultSelector2m 29s
-
Iterate over groups1m 44s
-
Combine two sequences3m 47s
-
Flatten sequence with SelectMany2m 15s
-
Challenge: Group results by color values2m 30s
-
Solution: Group results by color values1m 35s
-
-
-
-
-
-
-