What is the difference between Select and SelectMany?
Short answer
Select projects one-to-one (giving a sequence of sequences if the selector returns a collection); SelectMany flattens those into one sequence.
Advertisement
AModel answer
Select projects one-to-one (giving a sequence of sequences if the selector returns a collection); SelectMany flattens those into one sequence.
var tags = posts.Select(p => p.Tags); // IEnumerable<List<string>>
var flat = posts.SelectMany(p => p.Tags); // IEnumerable<string>Real-world example
Getting one flat list of all line items across all orders.