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.
Flatten sequence with SelectMany - .NET Tutorial
From the course: .NET Essentials: Working with LINQ
Flatten sequence with SelectMany
- [Instructor] How many times in this course have we used the SELECT clause, or the select extension method? I don't know the number but it's a lot. What I want to look at in this video is a related method called SelectMany. I put it in the group chapter because it's kind of the opposite of grouping it's flattening a bunch of information, a bunch of items in a sequence. So let's think about groups for a minute, when you put items into group you end up with a group that has many elements. So that's a one to many relationship, there's the group and there's many values in that group. SelectMany, also works with a one to many relationship, but it takes all of the groups of information and flattens them out into a single sequence. So to make this work, I created some new types here. I created a class called HistoryCalendar, has a decade which is a string and then and this is the many relationship, it has a list of ints which I…
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
-
-
-
-
-
-
-