SelectMany operator in Linq C#

added by jalpesh
1/31/2013 1:12:00 PM

0 Kicks, 58 Views

SelectMany is an important operator in Linq. It takes each element of a sequence to an IEnumerable and flattens the resulting sequences into one sequence. You can find out more information about different overload list from the below link. In this post I am going to explain How it can be really useful when you want to find list related to two entities. Practical example will be like a person can have multiple address and if you want to find list of addresses that are used with person then this SelectMany operator can be really useful. So for this example First, I have create Address class with Street and Postalvcode property