title: Transpose data into dictionary of int and list
body: <p>I have data in my database stored as</p>
  
  <p>ID        DateID     Country        NoOfPeople</p>
  
  <p>2    20130301   Indonesia   2</p>
  
  <p>3    20130301   Malaysia    128</p>
  
  <p>4    20130301   United Kingdom  2</p>
  
  <p>6    20130302   Australia   1</p>
  
  <p>24   20130303   Australia   2</p>
  
  <p>25   20130303   Bhutan  11</p>
  
  <p>26   20130303   Canada  1</p>
  
  <p>27   20130303   Fiji    1</p>
  
  <p>28   20130303   Finland 1</p>
  
  <p>52   20130304   Australia   2</p>
  
  <p>53   20130304   Bhutan  10</p>
  
  <p>54   20130304   Canada  1</p>
  
  <p>55   20130304   Fiji    1</p>
  
  <p>I wish to transpose this data into a dictionary where the DateID is the key and the value is a list of country objects with properties for the country and noOfPeople</p>
  
  <p>i.e. <code>Dictionary&lt;int, List&lt;Country&gt;&gt;</code></p>
  
  <p>I return the data to my application using LINQ and then traverse the results creating a list of the countries and numbers for each unique date id. This works but I’m looking for a more elegant and efficient solution.</p>
  
  <p>My ultimate goal is to outpout JSON in the format</p>
  
  <pre><code>PeopleByCountry":{
  
  "20130301":
  
  [
  
  {"country":"Indonesia"," noOfPeople ":2},
  {"country":"Malaysia"," noOfPeople ":128},
  {"country":"United Kingdom"," noOfPeople ":2}
  ],
  
  "20130302":
  [
  {"country":"Indonesia","noOfPeople":1},
  {"country":"Australia"," noOfPeople ":1}
  ]
  }
  </code></pre>
  
  <p>Which I’m doing with NewtonSoft.</p>
  
  <p>Hope this makes sense.</p>
  
  <p>Thanks in advance.</p>