/// <summary> /// Selecciona todas las ciudades /// (miturriaga) /// </summary> /// <returns>La lista de ciudades</returns> public static List<City> Todos() { var cities = new List<City>(); try { string connString = ConfigurationManager.ConnectionStrings["PostgresConnection"].ConnectionString; var comando = new NpgsqlCommand() { CommandText = "City_Todos", CommandType = CommandType.StoredProcedure }; using (var conn = new NpgsqlConnection(connString)) { conn.Open(); comando.Connection = conn; NpgsqlDataReader ds = comando.ExecuteReader(); while (ds.Read()) { var city = new City(); city.SetDesde(ds); cities.Add(city); } conn.Close(); } } catch (Exception ex) { } return cities; }
public List<City> AeropuertosTodos() { var passengers = new List<City>(); try { string connString = ConfigurationManager.ConnectionStrings["PostgresConnection"].ConnectionString; var comando = new NpgsqlCommand() { CommandText = "SELECT * FROM \"City\"" }; using (var conn = new NpgsqlConnection(connString)) { conn.Open(); comando.Connection = conn; NpgsqlDataReader ds = comando.ExecuteReader(); while (ds.Read()) { var ciudad = new City(); ciudad.SetDesde(ds); passengers.Add(ciudad); } conn.Close(); } } catch (Exception ex) { } return passengers; }