title: How do I create a nested group-by dictionary using LINQ?
body: <p>How would I create a nested grouping for the table below, using LINQ? I want to group by <code>Code</code>, then by <code>Mktcode</code>.</p>
  
  <pre><code>Code Mktcode Id
  ==== ======= ====
  1    10      0001 
  2    20      0010 
  1    10      0012 
  1    20      0010 
  1    20      0014 
  2    20      0001
  2    30      0002
  1    30      0002
  1    30      0005
  </code></pre>
  
  <p>I'd like a dictionary, in the end, like </p>
  
  <pre><code>Dictionary&lt;Code, List&lt;Dictionary&lt;Mktcode, List&lt;Id&gt;&gt;&gt;&gt;
  </code></pre>
  
  <p>So the values of this dictionary would be</p>
  
  <pre><code>{1, ({10,(0001,0012)}, {20,(0010,0014)}, {30, (0002, 0005)})},
  {2, ({20,(0001, 0010)}, {30, (0020)} )}
  </code></pre>