You can use the SelectMany
LINQ extension method to achieve the same behavior as the foreach loop. Here is how to do it:
main.cs180 chars3 lines
The SelectMany
method flattens a sequence of sequences into a single sequence. It takes a function that returns a sequence for each element in the input sequence, and concatenates all the resulting sequences into a single sequence.
In this case, the function returns the linked subarticles for each EventArticle
, and ToList
is used to create a list from the resulting sequence.
gistlibby LogSnag