I have a simple table that I would like to get the last inserted rows from using GroupBy.
I have the following code that works without grouping but would like to make a new function with grouping
public Session FindLastFinished(IdentityUser user)
{
return _dbContext.Sessions.OrderByDescending(o => o.CreatedAt).FirstOrDefault(s => s.User.Equals(user) && s.Progress.Equals(Status.Finished.ToString()));
}
I need to add a grouping for the column ScenarioId so that it will return the last inserted row for each ScenarioId but am having trouble adding the GroupBy syntax.
public List<Session> FindLastFinishedByScenarios(IdentityUser user)