I can flatten the results of a child collection within a collection with SelectMany:

 // a list of Foos, a Foo contains a List of Bars
 var source = new List<Foo>() { ... };

 var q = source.SelectMany(foo => foo.Bar)
     .Select(bar => bar.barId)
 .ToList();

this gives me the list of all Bar Ids in the Foo List. When I attempt to go three levels deep the incorrect result is returned.

 var q = source.SelectMany(foo => foo.Bar)
     .SelectMany(bar => bar.Widget)
         .Select(widget => widget.WidgetId)
 .ToList();

How should I be using SelectMany to get the list of all Widgets in all Bars in my list of Foos?

Edit I miss-worded the above sentence, but the code reflects the goal. I am looking for a list of all Widget Ids, not widgets.

An "incorrect" result is not all of the widget ids are returned.

Edit
Report