public VegaObject Insert() { VegaObject obj = null; if (InsertQuery == null) { InsertQuery = BuildInsertQuery(); } using (NpgsqlCommand cmd = new NpgsqlCommand(InsertQuery, Connection, Transaction)) { SetPrimaryKeyParameters(cmd); SetDataParameters(cmd); using (NpgsqlDataReader reader = cmd.ExecuteReader()) { if (!reader.Read()) { return(null); } obj = ReadObject(reader); } } return(obj); }
public VegaObject Update() { VegaObject obj = null; String query; if (UpdateUseNulls) { if (UpdateNullsQuery == null) { UpdateNullsQuery = BuildUpdateQuery(UpdateUseNulls); } query = UpdateNullsQuery; } else { if (UpdateQuery == null) { UpdateQuery = BuildUpdateQuery(UpdateUseNulls); } query = UpdateQuery; } using (NpgsqlCommand cmd = new NpgsqlCommand(query, Connection, Transaction)) { SetPrimaryKeyParameters(cmd); SetDataParameters(cmd); using (NpgsqlDataReader reader = cmd.ExecuteReader()) { if (!reader.Read()) { return(null); } obj = ReadObject(reader); } } return(obj); }