title: LINQ - GroupBy a key and then put each grouped item into separate 'buckets'
body: <p>I have a list of items as such:</p>
  
  <pre><code>public class Item
  {
      public int ItemId { get; set; }
      public string ItemName { get; set; }
      public int ListId { get; set; }
  }
  </code></pre>
  
  <p><code>1 Test1 1</code></p>
  
  <p><code>2 Test2 1</code></p>
  
  <p><code>3 Test3 1</code></p>
  
  <p><code>4 List 2</code></p>
  
  <p><code>5 List2 2</code></p>
  
  <p><code>6 Testing 3</code></p>
  
  <p><code>7 Testing2 3</code></p>
  
  <p><code>8 Testing3 3</code></p>
  
  <p>Is there a way for me to group by the <code>ListId</code> and put them into each separate buckets, i.e, <code>ListId1</code> bucket will have all items with <code>ListId == 1</code>. The list is dynamically returned from SQL, so I don't know before hand how many <code>ListId</code> there will be.</p>