/// <summary> /// Converts <see cref="System.Data.DataRow"/> to <see cref="lkpComplainanttypeRow"/>. /// </summary> /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param> /// <returns>A reference to the <see cref="lkpComplainanttypeRow"/> object.</returns> protected virtual lkpComplainanttypeRow MapRow(DataRow row) { lkpComplainanttypeRow mappedObject = new lkpComplainanttypeRow(); DataTable dataTable = row.Table; DataColumn dataColumn; // Column "Comp_TypeID" dataColumn = dataTable.Columns["Comp_TypeID"]; if (!row.IsNull(dataColumn)) { mappedObject.Comp_TypeID = (int)row[dataColumn]; } // Column "Comp_Name" dataColumn = dataTable.Columns["Comp_Name"]; if (!row.IsNull(dataColumn)) { mappedObject.Comp_Name = (string)row[dataColumn]; } // Column "Active" dataColumn = dataTable.Columns["Active"]; if (!row.IsNull(dataColumn)) { mappedObject.Active = (bool)row[dataColumn]; } return(mappedObject); }
/// <summary> /// Updates a record in the <c>lkpComplainanttype</c> table. /// </summary> /// <param name="value">The <see cref="lkpComplainanttypeRow"/> /// object used to update the table record.</param> /// <returns>true if the record was updated; otherwise, false.</returns> public virtual bool Update(lkpComplainanttypeRow value) { IDbCommand cmd = _db.CreateCommand("dbo._lkpComplainanttype_Update", true); AddParameter(cmd, "Comp_Name", value.Comp_Name); AddParameter(cmd, "Active", value.IsActiveNull ? DBNull.Value : (object)value.Active); AddParameter(cmd, "Comp_TypeID", value.Comp_TypeID); return(0 != cmd.ExecuteNonQuery()); }
/// <summary> /// Adds a new record into the <c>lkpComplainanttype</c> table. /// </summary> /// <param name="value">The <see cref="lkpComplainanttypeRow"/> object to be inserted.</param> public virtual void Insert(lkpComplainanttypeRow value) { IDbCommand cmd = _db.CreateCommand("dbo._lkpComplainanttype_Insert", true); AddParameter(cmd, "Comp_TypeID", value.Comp_TypeID); AddParameter(cmd, "Comp_Name", value.Comp_Name); AddParameter(cmd, "Active", value.IsActiveNull ? DBNull.Value : (object)value.Active); cmd.ExecuteNonQuery(); }
/// <summary> /// Reads data from the provided data reader and returns /// an array of mapped objects. /// </summary> /// <param name="reader">The <see cref="System.Data.IDataReader"/> object to read data from the table.</param> /// <param name="startIndex">The index of the first record to map.</param> /// <param name="length">The number of records to map.</param> /// <param name="totalRecordCount">A reference parameter that returns the total number /// of records in the reader object if 0 was passed into the method; otherwise it returns -1.</param> /// <returns>An array of <see cref="lkpComplainanttypeRow"/> objects.</returns> protected virtual lkpComplainanttypeRow[] 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 comp_TypeIDColumnIndex = reader.GetOrdinal("Comp_TypeID"); int comp_NameColumnIndex = reader.GetOrdinal("Comp_Name"); int activeColumnIndex = reader.GetOrdinal("Active"); System.Collections.ArrayList recordList = new System.Collections.ArrayList(); int ri = -startIndex; while (reader.Read()) { ri++; if (ri > 0 && ri <= length) { lkpComplainanttypeRow record = new lkpComplainanttypeRow(); recordList.Add(record); record.Comp_TypeID = Convert.ToInt32(reader.GetValue(comp_TypeIDColumnIndex)); if (!reader.IsDBNull(comp_NameColumnIndex)) { record.Comp_Name = Convert.ToString(reader.GetValue(comp_NameColumnIndex)); } if (!reader.IsDBNull(activeColumnIndex)) { record.Active = Convert.ToBoolean(reader.GetValue(activeColumnIndex)); } if (ri == length && 0 != totalRecordCount) { break; } } } totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1; return((lkpComplainanttypeRow[])(recordList.ToArray(typeof(lkpComplainanttypeRow)))); }
/// <summary> /// Deletes the specified object from the <c>lkpComplainanttype</c> table. /// </summary> /// <param name="value">The <see cref="lkpComplainanttypeRow"/> object to delete.</param> /// <returns>true if the record was deleted; otherwise, false.</returns> public bool Delete(lkpComplainanttypeRow value) { return(DeleteByPrimaryKey(value.Comp_TypeID)); }