LINQ C# Book

public void Linq19()
{
List customers = GetCustomerList();

var customerOrders =
customers.SelectMany(
(cust, custIndex) =>
cust.Orders.Select(o => "Customer #" + (custIndex + 1) +
" has an order with OrderID " + o.OrderID));

ObjectDumper.Write(customerOrders);
}


Result

Customer #1 has an order with OrderID 10643
Customer #1 has an order with OrderID 10692
Customer #1 has an order with OrderID 10702
Customer #1 has an order with OrderID 10835
Customer #1 has an order with OrderID 10952
Customer #1 has an order with OrderID 11011
Customer #2 has an order with OrderID 10308
Customer #2 has an order with OrderID 10625
Customer #2 has an order with OrderID 10759
Customer #2 has an order with OrderID 10926

...
Customer #90 has an order with OrderID 10248
Customer #90 has an order with OrderID 10615
Customer #90 has an order with OrderID 10673
Customer #90 has an order with OrderID 10695
Customer #90 has an order with OrderID 10873
Customer #90 has an order with OrderID 10879
Customer #90 has an order with OrderID 10910
Customer #90 has an order with OrderID 11005
Customer #91 has an order with OrderID 10374
Customer #91 has an order with OrderID 10611
Customer #91 has an order with OrderID 10792
Customer #91 has an order with OrderID 10870
Customer #91 has an order with OrderID 10906
Customer #91 has an order with OrderID 10998
Customer #91 has an order with OrderID 11044