a) Would the following two queries produce the same results:
var query1 = collection_1
.SelectMany(c_1 => c_1.collection_2)
.Se
a. The queries are equal because in both cases you end up with all c_3
's in c_1
through c_2
.
b. You can't get to c_1
and c_2
with these queries as you suggest. If you want that you need this overload of SelectMany
. This "fluent" syntax is quite clumsy though. This is typically a case where comprehensive syntax which does the same is much better:
from c_1 in colection_1
from c_2 in c_1.collection_2
from c_3 in c_2.collection_3
select new { c_1.x, c_2.y, c_3.z }