title: Linq (GroupBy and Sum) over List<List<string>>
body: <p>I have a structure: </p>
  
  <pre><code>List&lt;List&lt;string&gt;&gt; content
  </code></pre>
  
  <p>This is bascially the content from a comma seperated file. The first element in the list will be a list of strings representing the headers. All other element in the list will be a list of strings representing the values.</p>
  
  <p>I am trying to run a query like below. Where "code" and "book" are two headers and I need to group by them 2 and sum by another header. This is my attemp but of course I cannot use the Groupby on the content directly as it is a list of lists. </p>
  
  <pre><code>List&lt;List&lt;string&gt;&gt; content = MyContent();
  
  var linqResults = content
                    .GroupBy(x =&gt; new { Code = x["code"], Book = x["book"] })
                    .Select(g =&gt;
                     {
                         return new
                         {
                             Book = g.Key.Book,
                             Code = g.Key.Code,
                             Total = g.SelectMany(x =&gt; x["columnToSum"].Sum())
                         };
                     });
  </code></pre>