title: How to show data in MVC View coming from Group by query
body: <p>I am trying to return records from db and group by Transaction Date so I can see only one record for each specific date in the view if I have multiple transactions in the same day. I did the query and it is working fine but the view is not displaying the result and I am getting an error: </p>
  
  <blockquote>
    <p>The model item passed into the dictionary is of type 'System.Collections.Generic.List<code>1[System.Linq.IGrouping</code>2[System.DateTime,TouchlessWeb.Models.ClientAccounting]]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[TouchlessWeb.Models.ClientAccounting]'.</p>
  </blockquote>
  
  <p><strong>My controller Code:</strong></p>
  
  <pre><code>var query = db.clientAccountings.Where(u =&gt; u.OrgId == id).GroupBy(o =&gt; o.TransDate);
                  return View(query.ToList());
  </code></pre>
  
  <p><strong>and My View:</strong></p>
  
  <pre><code>@model IEnumerable&lt;TouchlessWeb.Models.ClientAccounting&gt;
  @foreach (var user in Model)
              {
              &lt;tbody&gt;
                  &lt;tr&gt;
                      &lt;td&gt;@user.TransDate &lt;/td&gt;
                      &lt;td&gt;RM @user.Amount&lt;/td&gt;
                      &lt;td&gt;
                          @if (user.AccType == 1)
                          {
                              &lt;span class="text-danger"&gt;Seasonal&lt;/span&gt;
                          }
                          @if (user.AccType == 2)
                          {
                              &lt;span&gt;Occasional&lt;/span&gt;
                          }
  
                      &lt;/td&gt;
                      &lt;td&gt;@user.TransID&lt;/td&gt;
                      &lt;td&gt;Not Paid&lt;/td&gt;
                      &lt;td&gt;@user.RefNo&lt;/td&gt;
  
  
                  &lt;/tr&gt;
              &lt;/tbody&gt;
              }
  </code></pre>
  
  <p>I am new to MVC, I hope you can help me. Thanks</p>