Entity Framework – Eliminating a discrepancy between controller output and model expected from the page

I have a problem where my controller does not return the type that my page model expects.

My controller sends a kind of:

    IEnumerable <list> grouped

And my site is expecting a model of the type:


The problem is, no matter what I try, I can not make them match.

Here is the error:

An unhandled exception occurred while processing the request.
InvalidOperationException: The model element passed to
ViewDataDictionary is of the type
System.Linq.Enumerable + SelectEnumerableIterator2[SystemLinqIGrouping[SystemLinqIGrouping[SystemLinqIGrouping[SystemLinqIGrouping2[System.Int32,EFGameManager.Models.GameList.GameSession], System.Collections.Generic.List1[EFGameManager.Models.GameList.GameSession]]& # 39 ;,
However, this ViewDataDictionary instance requires a model element of type
System.Collections.Generic.IEnumerable; & # 39
1[EFGameManager.Models.GameList.GameSession]& # 39 ;.
Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary.EnsureCompatible (Object

Here is the model that expects the page:


@model IEnumerable

Here is the controller:

public async task Index (DateTime Start, DateTime End)
var eventGames = waitit _context.GameList
.Where (m => m.GameCatalogId! = Zero) .ToListAsync ();

var eventPlayers = waitit _context.PlayerList
.Where (p => p.PlayerType == 2) .ToListAsync ();

var query = from pl in eventPages
Join ml in eventGames on fl.GameId equals ml.GameId
Choose a new GameSession
Id = pl.ListingId,
GameId = ml.GameId,
SessionGameName = ml.GameDisplayName,
SessionEventName = pl.ListingDisplayName,
SessionStartTime = pl.PlayerStartTime,
SessionEndTime = pl.PlayerEndTime

var orderedResults = Query
.OrderBy (n => n.SessionGameName)
.DhenBy (d => d.SessionDate)
.ThenBy (t => t.SessionStartTime) .ToList ();

var ts = TimeSpan.FromMinutes (30);

var grouped = Assorted results
.OrderBy (r => r.GameId)
.ThenBy (r => r.SessionDate)
.ThenBy (r => r.SessionStartTime)
.GroupByWhile ((p, n) => p.SessionDate.Value.Date == n.SessionDate.Value.Date
&& n.SessionStartTime - p.SessionEndTime < ts)
                            .Select(rg => rg.ToList ());

return view (grouped);

I've tried a few things and either get a new bug or a variation of that bug.

Any insight would be very grateful!