protected virtual RoleRow MapRow(DataRow row) { RoleRow mappedObject = new RoleRow(); DataTable dataTable = row.Table; DataColumn dataColumn; // Column "Role_ID" dataColumn = dataTable.Columns["Role_ID"]; if (!row.IsNull(dataColumn)) { mappedObject.Role_ID = (int)row[dataColumn]; } // Column "Role_Name" dataColumn = dataTable.Columns["Role_Name"]; if (!row.IsNull(dataColumn)) { mappedObject.Role_Name = (string)row[dataColumn]; } // Column "Role_Description" dataColumn = dataTable.Columns["Role_Description"]; if (!row.IsNull(dataColumn)) { mappedObject.Role_Description = (string)row[dataColumn]; } return(mappedObject); }
public virtual bool Update(RoleRow value) { string sqlStr = "UPDATE [dbo].[Role] SET " + "[Role_Name]=" + _db.CreateSqlParameterName("Role_Name") + ", " + "[Role_Description]=" + _db.CreateSqlParameterName("Role_Description") + " WHERE " + "[Role_ID]=" + _db.CreateSqlParameterName("Role_ID"); IDbCommand cmd = _db.CreateCommand(sqlStr); AddParameter(cmd, "Role_Name", value.Role_Name); AddParameter(cmd, "Role_Description", value.Role_Description); AddParameter(cmd, "Role_ID", value.Role_ID); return(0 != cmd.ExecuteNonQuery()); }
public virtual void Insert(RoleRow value) { string sqlStr = "INSERT INTO [dbo].[Role] (" + "[Role_Name], " + "[Role_Description]" + ") VALUES (" + _db.CreateSqlParameterName("Role_Name") + ", " + _db.CreateSqlParameterName("Role_Description") + ");SELECT @@IDENTITY"; IDbCommand cmd = _db.CreateCommand(sqlStr); AddParameter(cmd, "Role_Name", value.Role_Name); AddParameter(cmd, "Role_Description", value.Role_Description); value.Role_ID = Convert.ToInt32(cmd.ExecuteScalar()); }
protected virtual RoleRow[] MapRecords(IDataReader reader, int startIndex, int length, ref int totalRecordCount) { if (0 > startIndex) { throw new ArgumentOutOfRangeException("startIndex", startIndex, "StartIndex cannot be less than zero."); } if (0 > length) { throw new ArgumentOutOfRangeException("length", length, "Length cannot be less than zero."); } int role_IDColumnIndex = reader.GetOrdinal("Role_ID"); int role_NameColumnIndex = reader.GetOrdinal("Role_Name"); int role_DescriptionColumnIndex = reader.GetOrdinal("Role_Description"); System.Collections.ArrayList recordList = new System.Collections.ArrayList(); int ri = -startIndex; while (reader.Read()) { ri++; if (ri > 0 && ri <= length) { RoleRow record = new RoleRow(); recordList.Add(record); record.Role_ID = Convert.ToInt32(reader.GetValue(role_IDColumnIndex)); if (!reader.IsDBNull(role_NameColumnIndex)) { record.Role_Name = Convert.ToString(reader.GetValue(role_NameColumnIndex)); } if (!reader.IsDBNull(role_DescriptionColumnIndex)) { record.Role_Description = Convert.ToString(reader.GetValue(role_DescriptionColumnIndex)); } if (ri == length && 0 != totalRecordCount) { break; } } } totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1; return((RoleRow[])(recordList.ToArray(typeof(RoleRow)))); }
public bool Delete(RoleRow value) { return(DeleteByPrimaryKey(value.Role_ID)); }