This question already has an answer here:

Im trying to get a list of league games and am getting

An exception of type 'System.NotSupportedException'occurred in EntityFramework.SqlServer.dll but was not handled in user code

My code for the view is as follows:

public ActionResult viewSchedule(int? id)
    int leagueId = (int)id;
    int seasonYear = getSeasonYear();

    League league = db.Leagues.Find(leagueId);
    var leagueGames = db.Games.Where(l => l.League == league).Where(g => g.SeasonDate == seasonYear);

    return View(leagueGames.ToList());         

and the view model is:

@model IEnumerable

Related posts

Recent Viewed