Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 18005

Issue on Using Group by on Lambda and IEnumerable - ASP.Net

$
0
0

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.List1[System.Linq.IGrouping2[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?


Viewing all articles
Browse latest Browse all 18005

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>