private List <Factions.Faction> DbToFaction(NpgsqlDataReader reader) { List <Factions.Faction> rtn = new List <Factions.Faction>(); while (reader.Read()) { Factions.Faction temp = new Factions.Faction(); for (int i = 0; i < reader.GetColumnSchema().Count(); i++) { helpers.SetPropValue(temp, reader.GetColumnSchema()[i].ColumnName, reader.GetValue(i).ToString()); } rtn.Add(temp); } return(rtn); }
public Factions.Faction get_faction(NpgsqlConnection con, int id) { con.Open(); Factions.Faction rtn = new Factions.Faction(); using (var cmd = new NpgsqlCommand()) { cmd.Connection = con; cmd.CommandText = "SELECT * FROM factions where factions.\"Id\" = @id;"; cmd.Parameters.AddWithValue("id", id); using (var reader = cmd.ExecuteReader()) { rtn = DbToFaction(reader)[0]; } con.Close(); return(rtn); } }