title: How to use groupby and select to solve this problem
body: <p>Given that i have 3 classed like below</p>
  <pre><code>public class Item1DTO
  {
      public int sId { get; set; }
      public int groupId { get; set; }
      public string name { get; set; }
      public string year { get; set; }
  
  }
  
  public class Item1
  {
      public string name { get; set; }
      public string year { get; set; }
  }
  
  public class Item1VM
  {
      public int sId { get; set; }
      public int groupId { get; set; }
  
      public List&lt;Item1&gt; items { get; set; }
  
  }
  </code></pre>
  <p>And sample data</p>
  <pre><code>List&lt;Item1DTO&gt; data = new List&lt;Item1DTO&gt;();
  data.Add(new Item1DTO { sId = 1, groupId = 1, name = &quot;item1&quot;, year = &quot;2019&quot; });
  data.Add(new Item1DTO { sId = 1, groupId = 1, name = &quot;item1&quot;, year = &quot;2020&quot; });
  data.Add(new Item1DTO { sId = 1, groupId = 2, name = &quot;item1&quot;, year = &quot;2020&quot; });
  data.Add(new Item1DTO { sId = 1, groupId = 2, name = &quot;item1&quot;, year = &quot;2020&quot; });
  data.Add(new Item1DTO { sId = 1, groupId = 3, name = &quot;item1&quot;, year = &quot;2020&quot; });
  </code></pre>
  <p>I want to group this data by groupId and result will be a List of Item1VM class
  so it can converted to this json data</p>
  <pre><code>[
      {
          &quot;sid&quot;: 1,
          &quot;groupId&quot;: 1,
          &quot;items&quot;: [
              {
                  &quot;name&quot;: &quot;item1&quot;,
                  &quot;year&quot;: 2019
              },
              {
                  &quot;name&quot;: &quot;item1&quot;,
                  &quot;year&quot;: 2020
              }
          ]
      },
      {
          &quot;sid&quot;: 1,
          &quot;groupId&quot;: 2,
          &quot;items&quot;: [
              {
                  &quot;name&quot;: &quot;item1&quot;,
                  &quot;year&quot;: 2020
              },
              {
                  &quot;name&quot;: &quot;item1&quot;,
                  &quot;year&quot;: 2020
              }
          ]
      },
      {
          &quot;sid&quot;: 1,
          &quot;groupId&quot;: 3,
          &quot;items&quot;: [
              {
                  &quot;name&quot;: &quot;item1&quot;,
                  &quot;year&quot;: 2020
              }
          ]
      }
  ]
  </code></pre>
  <p>Have tried my combination but im kinda new so the result is not as expected.</p>