title: Entity Framework | GroupBy and Sum
body: <p>I have a simple table which only has 3 columns <code>{ id, DateTime, NumberOfCoils }</code>, I need to get the results of the query grouped together by the <code>DateTime</code> with the sum of the <code>NumberOfCoils</code> on that particular date.</p>
  
  <pre><code>return testData.MOCK_DATA.Select(x =&gt; new { x.NumberOfCoils, x.DateTime })
              .AsEnumerable()
              .Where(x =&gt; x.DateTime&gt; DateTime.Now.AddDays(-numberOfDays))
              .Select(x =&gt; new { formattedDate = x.DateTime.ToString("yyyy-MM-dd"), x.NumberOfCoils })
              .OrderBy(x =&gt; x.formattedDate)
              .ToList();
  </code></pre>
  
  <p>I've looked for solutions here but I couldn't figure out how to solve it. I think that part of what's making it hard for me to find a solution is because I have to do some formatting as well. </p>
  
  <p>I'm pretty new to using EF so I apologize if this is a bad question.</p>