title: Create a dictionary on a list with grouping
body: <p>I have the following object in a list:</p>
  
  <pre><code>public class DemoClass
  {
      public int GroupKey { get; set; }
      public string DemoString { get; set; }
      public object SomeOtherProperty { get; set; }
  }
  </code></pre>
  
  <p>Now, I want to create following dictionary out of it:</p>
  
  <pre><code>Dictionary&lt;int, List&lt;DemoClass&gt;&gt;
  </code></pre>
  
  <p>I want to group the <code>List&lt;DemoClass&gt;</code> by the property <code>GroupKey</code>, but I don't understand how this is done and some help.</p>
  
  <p>After thinking a bit, I achieved the needed behaviour with:</p>
  
  <pre><code>var groupedDemoClasses = from demoClass in mySepcialVariableWhichIsAListOfDemoClass
                              group demoClass by demoClass.GroupKey
                              into groupedDemoClass
                              select groupedDemoClass;
  var neededDictionary = groupedDemoClass.ToDictionary(gdc =&gt; gdc.Key, gdc =&gt; gdc.ToList());
  </code></pre>
  
  <p>but, is there a way to make this into a single statement?</p>