I need to render list of events (games) Grouped by
the CreateDate
In controller I have
public ActionResult Index(){ var gs = db.Games.Include(p => p.Activity).GroupBy(e => e.CreateDate); return View(gs.ToList());}
and in the view I have
@model IEnumerable<Game><h2>Games List:</h2><table> @foreach (Game e in Model) {<thead><tr><td colspan="2"><b>@e.CreateDate</b></td></tr></thead> }<tr><td><b>@e.GameStartTime - @e.GameEndTime</b></td><td><b>@e.Activity.ActivityDescription</b></td></tr></table>
But I am getting this error
The model item passed into the dictionary is of type 'System.Collections.Generic.List
1[System.Linq.IGrouping
2[System.DateTime,MapApp.Models.Event.Event]]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[MapApp.Models.Event.Event]'.
What am I doing wrong?