public IList <DmGroupUsers> GetAll() { IList <DmGroupUsers> list = new List <DmGroupUsers>(); using (dynamic connection = connectionFactory.GetConnection()) { String sql = "SELECT r_object_id, r_modify_date, r_creation_date, dsid_doctor_id, dss_group_name FROM dm_group_users"; Logger.Debug(CultureInfo.CurrentCulture, "SQL: {0}", sql); Npgsql.NpgsqlCommand command = new Npgsql.NpgsqlCommand(sql, connection); using (DbDataReader reader = command.ExecuteReader()) { while (reader.Read()) { DmGroupUsers obj = new DmGroupUsers(); obj.ObjectId = reader.IsDBNull(0) ? null : reader.GetString(0); obj.ModifyDate = reader.IsDBNull(1) ? DateTime.MinValue : reader.GetDateTime(1); obj.CreationDate = reader.IsDBNull(2) ? DateTime.MinValue : reader.GetDateTime(2); obj.DoctorId = reader.IsDBNull(3) ? null : reader.GetString(3); obj.GroupName = reader.IsDBNull(4) ? null : reader.GetString(4); list.Add(obj); } } } return(list); }
public DmGroupUsers GetById(string id) { using (dynamic connection = connectionFactory.GetConnection()) { String sql = String.Format("SELECT r_object_id, r_modify_date, r_creation_date, dsid_doctor_id, dss_group_name FROM dm_group_users WHERE r_object_id = '{0}'", id); Logger.Debug(CultureInfo.CurrentCulture, "SQL: {0}", sql); Npgsql.NpgsqlCommand command = new Npgsql.NpgsqlCommand(sql, connection); using (DbDataReader reader = command.ExecuteReader()) { if (reader.Read()) { DmGroupUsers obj = new DmGroupUsers(); obj.ObjectId = reader.IsDBNull(0) ? null : reader.GetString(0); obj.ModifyDate = reader.IsDBNull(1) ? DateTime.MinValue : reader.GetDateTime(1); obj.CreationDate = reader.IsDBNull(2) ? DateTime.MinValue : reader.GetDateTime(2); obj.DoctorId = reader.IsDBNull(3) ? null : reader.GetString(3); obj.GroupName = reader.IsDBNull(4) ? null : reader.GetString(4); return(obj); } } } return(null); }