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.

GroupBy query expression

GroupBy query expression

- [Narrator] Here's the syntax for working with GroupBy in a query expression. So, you don't use the word GroupBy in one word, you split it into two parts, the word group and the word by. So, let's read how this works, alright. Let's look at the Syntech. So, I'm saying I want to group this value, and the condition or the expression that I want to group on is by this value here. So, this is the same code I showed you, in the previous video, I'm going to get the same results I should say. There's here 11 groups. Now of course I don't have to filter on this property. Any valid expression can be written here. So, remember what I said in the last video, the expression determines what the key is, and it's also the determiner for which items belong in that group. So, let's say that I filter this by, I should say GroupBy GreenValue. Now how many groups do you think I'll get? 72 groups, so, if there's a GreenValue of zero,…

Contents