Как присвоить выбранные значения списку с помощью linq
var result = (from r in db.Routes join tin in db.TripIns on r.RouteId equals tin.RouteId join tout in db.TripOuts on r.RouteId equals tout.RouteId select new { RouteId = r.RouteId, RouteName = r.RouteName, RouteDesc = r.RouteDesc, tripins = new TripIn{ TripInId = tin.TripInId, TripInName = tin.TripInName }, tripouts = new TripOut { TripOutId = tout.TripOutId, TripOutName = tout.TripOutName } }).ToList() .Select(x => new Route() { RouteId = x.RouteId, RouteName = x.RouteName, RouteDesc = x.RouteDesc, TripIns = x.tripins, TripOuts = x.tripouts });
Что я уже пробовал:
var result = (from r in db.Routes join tin in db.TripIns on r.RouteId equals tin.RouteId join tout in db.TripOuts on r.RouteId equals tout.RouteId select new { RouteId = r.RouteId, RouteName = r.RouteName, RouteDesc = r.RouteDesc, tripins = new TripIn{ TripInId = tin.TripInId, TripInName = tin.TripInName }, tripouts = new TripOut { TripOutId = tout.TripOutId, TripOutName = tout.TripOutName } }).ToList() .Select(x => new Route() { RouteId = x.RouteId, RouteName = x.RouteName, RouteDesc = x.RouteDesc, TripIns = x.tripins, TripOuts = x.tripouts });