title: Transform ICollection .toDictionary() c#
body: <p>I am in a project that uses MVC4 with EntityFramework.</p>
  
  <p>In my C# code I access the database with a simple query that returns a package. Now a package has a list of items, and I need a dictionary with the Id and Name of those items. I achieve the following using this code:</p>
  
  <pre><code>Package pkg = (from aPkg in DB.Packages where aPkg.PackageId == id 
      select aPkg).First();
  
  Dictionary&lt;int, string&gt; materials = new Dictionary&lt;int,string&gt;();
  
  foreach(Material mat in pkg.Materials){
      materials.Add(mat.MaterialId, mat.Label);
  }
  </code></pre>
  
  <p>However this is quite verbose, and I noticed that there is another function that I can use: <code>pkg.Materials.toDictionary&lt;tKey, tElement&gt;()</code>. </p>
  
  <p>Unfortunatly, even after checking the official documentation, I cannot understand how to use this function to achieve the same goal in a less verbose way. How can I do it?</p>