title: LINQ grouping multiple columns with nested collection
body: <p>I am grouping a collection, by multiple columns. It is easy to group them if they are on this same level of nesting:</p>
  
  <pre><code>var groupedAirProducts = airproductsPerClient.GroupBy(ac =&gt; new
  {
      ac.AirProduct.PassengerNameRecord,
      ac.AirProduct.Flights.First().MarketingAirlineCode,
      ac.AirProduct.Flights.First().FlightNo,
      ac.AirProduct.Flights.First().DepartureDate
  })
  </code></pre>
  
  <p>The problem is that I don't want only to group by a first flight, but I want to include all the flights. What I would like to do is something like:</p>
  
  <pre><code>var groupedAirProducts= airproductsPerClient.GroupBy(ac =&gt;
  {
      ac.AirProduct.PassengerNameRecord,
      foreach(var flight in ac.AirProduct.Flights){
          flight.MarketingAirlineCode,
          flight.FlightNo,
          flight.DepartureDate
      }
  })
  </code></pre>
  
  <p>Please note that the code above is just an illustration of an idea. It is not a working/proper code. The only way I know how to do it is pretty ugly and complex. I was wondering if there is a nice way to do it using LINQ, or a simple way to tackle this problem.</p>
  
  <p>Edit:
  To explain more of what is expected. As a result of grouping I want to have collections of airProducts that share same PassengerNameRecord, and that flights that belong to a given air product share same MarketingAirlineCode, FlightNo, DepartureDate. I know how to implement it by flattering a collection of PassengerNameRecord, so the Flights are included in it, grouping it, so I have a groups of air products that share grouped properties. And then rebuilding the flattered structure. I was hoping that there is a way to either add groupBy properties by iterating thru some collection, or there is a way to merge grouped collection - if there is a way to have a collection grouped by PassengerNameRecord, and collection grouped by Flight properties and merging them together, unfortunately I doubt that there is an easy way to do such merge.</p>