From the course: .NET Essentials: Working with LINQ
Unlock this course with a free trial
Join today to access over 22,600 courses taught by industry experts.
Challenge: Group results by color values - .NET Tutorial
From the course: .NET Essentials: Working with LINQ
Challenge: Group results by color values
(upbeat music) - [Instructor] Are you ready for another code challenge? This time we'll look at how to write a query expression that uses the group by clause. I've already got some code written for you here. It's in this file in chapter nine, called challenge. And I've got some sample code written down the bottom, so you can just modify this if you want, or you can start writing from scratch if you'd rather. Remember a couple of things about group by, it uses an expression to determine the group key. So in my example here on line 24, the key is the saturation value. So when I run this, I get back 43 groups. The first one has a key 100, and there are other key values of course. So now that we know that, let's talk about this further. This can be any valid expression. So, this is a simple expression just using a property name, but I can also do calculations here like this less than 40. Now, when I run this, this is a…
Contents
-
-
-
-
-
-
-
-
-
-
-
The GroupBy method2m 27s
-
(Locked)
GroupBy query expression1m 53s
-
(Locked)
GroupBy with ElementSelector2m 36s
-
(Locked)
GroupBy with ResultSelector2m 29s
-
(Locked)
Iterate over groups1m 44s
-
(Locked)
Combine two sequences3m 47s
-
(Locked)
Flatten sequence with SelectMany2m 15s
-
(Locked)
Challenge: Group results by color values2m 30s
-
(Locked)
Solution: Group results by color values1m 35s
-
-
-
-
-
-
-