LINQ SelectMany in Depth
The Utility Knife for Nested Collections
In this article, I’ll walk through the various overloads and usages of LINQ’s SelectMany
methods.
SelectMany
is in many ways the opposite of GroupBy
which I covered last time in this series on LINQ. While GroupBy
took a single collection and transformed it into multiple child collections, SelectMany
flattens child collections into a single merged collection.
So, how is this flattening actually useful?