I have this linq query which I want to include group by some specific fields:
from x in db.Schedule
join y in db.Schedule on x.ID equals y.ID - 1
join z in db.Locations on x.Line.ToString() + '-' + x.Expedition equals z.LocationCode
where Convert.ToInt32(y.StopOrder) >= Convert.ToInt32(x.StopOrder) && x.NameOfTown == departingBusStation && dest.Contains(x.Line)
where x.NameOfTown == departingBusStation
select new { x.NameOfLine, x.DepartureTime, x.DestBusStationCode, x.StopOrder, z.LocationID }
In that linq query I want to add a group by x.DestBusStationCode
and x.DepartureTime
but modifying the query to something like this:
from x in db.Schedule
join y in db.Schedule on x.ID equals y.ID - 1
join z in db.Locations on x.Line.ToString() + '-' + x.Expedition equals z.LocationCode
where Convert.ToInt32(y.StopOrder) >= Convert.ToInt32(x.StopOrder) && x.NameOfTown == departingBusStation && dest.Contains(x.Line)
where x.NameOfTown == departingBusStation
orderby x.DepartureTime ascending
group x by new {x.DepartureTime, x.DestBusStationCode}
select new { x.NameOfLine, x.DepartureTime, x.DestBusStationCode, x.StopOrder, z.LocationID }
But I'm getting multiple errors with that approach.