public List <City> GetCities() { MySqlConnection conn = DB.Connection(); conn.Open(); MySqlCommand cmd = conn.CreateCommand() as MySqlCommand; cmd.CommandText = @"SELECT cities.* FROM flights JOIN cities_flights ON (flights.id = cities_flights.flight_id) JOIN cities ON (cities_flights.city_id = cities.id) WHERE flights.id = @FlightId;"; MySqlParameter flightIdParameter = new MySqlParameter(); flightIdParameter.ParameterName = "@FlightId"; flightIdParameter.Value = _id; cmd.Parameters.Add(flightIdParameter); MySqlDataReader rdr = cmd.ExecuteReader() as MySqlDataReader; List <City> cities = new List <City> { }; while (rdr.Read()) { int cityId = rdr.GetInt32(0); string cityName = rdr.GetString(1); City newCity = new City(cityName, cityId); cities.Add(newCity); } conn.Close(); if (conn != null) { conn.Dispose(); } return(cities); }