title: Group By Multiple Column In LINQ in C#
body: <p>I have a class like as follows:</p>
  
  <pre><code>public class ActualClass
  {
      public string BookName { get; set; }
      public string IssuerName { get; set; }
      public DateTime DateOfIssue { get; set; }
      public bool Status { get; set; }
  }
  </code></pre>
  
  <p>It has following data in the table:
  <a href="https://i.stack.imgur.com/cES1O.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cES1O.jpg" alt="enter image description here"></a></p>
  
  <p>I would like to group them by <em>IssuerName</em> and <em>DateOfIssue</em> for the following viewModel class:</p>
  
  <pre><code>public class ViewModel
  {
     public string IssuerName { get; set; }
     public DateTime DateOfIssue { get; set; }
     public List&lt;string&gt; Books { get; set; }
  }
  </code></pre>
  
  <p>And data will be displayed as follows: (<em>Screenshot data will be replaced by the previous table data after successful grouping</em>)
  <a href="https://i.stack.imgur.com/p0hFU.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/p0hFU.jpg" alt="enter image description here"></a></p>
  
  <p><strong>Special attention:</strong> <em>Is there anything wrong in my ViewModel according to my expectation?</em></p>
  
  <p>I tried a lot after following some stackoverflow answers but none did work for me. Any help will be highly appreciated.</p>
  
  <p>The code I have tried:</p>
  
  <pre><code>var viewmodel = from b in db.BookIssues
                  group b by new
                  {
                      b.IssuerName,
                      b.DateOfIssue
                  }
                  into g
                  select new ViewModel()
                  {
                      Name = g.key.IssuerName,
                      DateOfIssue = g.Key.DateOfIssue,
                      Books = g.ToList() //Actually this line of code is not working
                  };
  </code></pre>