Understanding the C# Linq SelectMany Operator

The Linq operator SelectMany has always confused me a bit, and yesterday I came across it in some code so had to actually try to understand it.

Simple put, SelectMany selects out all children from a collection of parents in a one to many parent child relation ship. You can add an additional parameter which provides access to the parent and child. Theres a good explanation on this stackoverflow answer. I wrote out the code in a console app (below) and it made a lot more sense:




Popular posts from this blog

A Simple 3 Layer Architecture