title: Return Linq Query into a List of KeyValuePair's
body: <p>I'm in the process of converting my chart application from preset data to using a database.</p>
  
  <p>Previously I was using this:</p>
  
  <pre><code>var data = new Dictionary&lt;string, double&gt;();            
  
  switch (graphselected)
  {        
  case "1":
      data = new Dictionary&lt;string, double&gt;
      {
          {"Dave", 10.023f},
          {"James", 20.020f},
          {"Neil", 19.203f},
          {"Andrew", 4.039f},
          {"Steve", 5.343f}
      };
      break;
  case "2":
      data = new Dictionary&lt;string, double&gt;
      {
          {"Dog", 10.023f},
          {"Cat", 20.020f},
          {"Owl", 19.203f},
          {"Rat", 16.039f},
          {"Bat", 27.343f}
      };
      break;
  //etc...
  }
  
  // Add each item in data in a foreach loop
  foreach (var item in list)
  {
      // Adjust the Chart Series values used for X + Y
      seriesDetail.Points.AddXY(item.Key, item.Value);
  } 
  </code></pre>
  
  <p>And this is what I'm trying to do:</p>
  
  <pre><code>var list = new List&lt;KeyValuePair&lt;string, double&gt;&gt;();
  
  switch (graphselected)
  {
  case "1":
      var query = (from x in db2.cd_CleardownCore
                   where x.TimeTaken &gt;= 10.0
                   select new { x.IMEI, x.TimeTaken }).ToList();
      list = query;                
      break;
  //...
  }
  </code></pre>
  
  <p>My code Error's on:</p>
  
  <pre><code>list = query; 
  </code></pre>
  
  <p>With Error :</p>
  
  <pre><code>Cannot implicitly convert type 'System.Collections.Generic.List&lt;AnonymousType#1&gt;'
  to 'System.Collections.Generic.List&lt;System.Collections.Generic.KeyValuePair&lt;string,double&gt;&gt;'
  </code></pre>
  
  <p>How can I implement a conversion?</p>