public List<MConnection> getNaborStations(int id) { List<MConnection> connections = new List<MConnection>(); using (ElectricCarEntities context = new ElectricCarEntities()) { var cs = from c in context.Connections where c.sId1 == id || c.sId2 == id select c; foreach (var c in cs) { MConnection mc = new MConnection(); if (c.sId1 == id) { mc.Station2 = getRecord(c.sId2, false); } else { mc.Station2 = getRecord(c.sId1, false); } mc.distance = c.distance; mc.driveHour = c.driveHour; connections.Add(mc); } } return connections; }
private MConnection buildConnection(Connection c) { MConnection connection = new MConnection() { distance = c.distance, driveHour = c.driveHour, Station1 = new MStation() { Id = c.sId1 }, Station2 = new MStation() { Id = c.sId2 } }; return connection; }