title: Convert Dictionary to List
body: <p>I have a list here generated from a long query which the data is used to pump to a report. </p>
  
  <pre><code>var result =  
    from..
    where..
    select new  { sale.Id, Username  = u.Name, Amount = p.amount};
  output  = result.Tolist();
  </code></pre>
  
  <p>However, i would like to get rid of that long query by creating my own list of value instead. So i create a dictionary to store the key and value. 
  My purpose is to convert a dictionary back to a list which has the same output like the query above so that it can be pumped to my report</p>
  
  <pre><code> public static object GetSalesDataBySaleOrderID(SaleOrder sale)
      {
          List&lt;KeyValuePair&lt;string, object&gt;&gt; list = new List&lt;KeyValuePair&lt;string, object&gt;&gt;();
  
          for (int i = 0; i &lt; sale.saleOrderItem.Count(); i++)
          {             
              Dictionary&lt;string, object&gt; result = new Dictionary&lt;string, object&gt;()
              {
                 {sale.Id.ToString(), sale.Id},                
                 {"UserName", sale.User.GetSingleUserById(sale.saleOrderItem[i].UserId).Name},
                 {"Amount", sale.saleOrderItem[i].Amount},                   
              };
  
              list.Add(result);
          }
  
          return list;
      }
  </code></pre>
  
  <p>I got an error at <code>list.Add(result);</code></p>
  
  <blockquote>
    <p>Error  5   Argument '1': cannot convert from 'System.Collections.Generic.Dictionary' to 'System.Collections.Generic.KeyValuePair'</p>
  </blockquote>
  
  <p><strong>---EDIT------------</strong><br>
  I have changed to <code>List&lt;Dictionary&lt;string, object&gt;&gt; list = new List&lt;Dictionary&lt;string, object&gt;&gt;();</code>   and it solved my error.  </p>
  
  <p>However i am still getting the value in dictionary format
  <img src="https://i.stack.imgur.com/RlNM4.jpg" alt="enter image description here"></p>
  
  <p>This should be the intended output format in List
  <img src="https://i.stack.imgur.com/TT21f.jpg" alt="enter image description here"></p>