我尝试在 Linq2SQL 中转换以下 SQL Select 语句:
SELECT stoptimes.stopid,
trips.tripid,
stoptimes.sequence
FROM trips
INNER JOIN stoptimes
ON stoptimes.tripid = trips.tripid
WHERE ( trips.routeid = '3' )
AND ( trips.endplace = 'END001' )
ORDER BY stoptimes.sequence DESC
它运行良好,但使用 linq2sql,以下语句出现异常:
var first = (from tableTrip in db.Trips
join tableStopTimes in db.StopTimes on tableTrip.TripId equals tableStopTimes.TripId
where tableTrip.RouteId == 3 && tableTrip.EndPlace == "TAEND"
select new
{
tableStopTimes.StopId,
tableStopTimes.Radius,
tableStopTimes.PlaceName,
tableStopTimes.Place,
tableStopTimes.Sequence
}).OrderByDescending(X => X.Sequence).First();
谢谢