Reputation: 8078
I have a querable collection of objects.
Each object contains a list.
I want to produce a list containing each element from the lists of each object in the collection.
How can I do this using linq or otherwise?
Upvotes: 1
Views: 88
Reputation: 888185
To flatten a nested list, use SelectMany
:
IEnumerable<ChildType> flattened = list.SelectMany(o => o.ChildList);
Upvotes: 5