/// <summary> /// Updates a record in the <c>lkpBit</c> table. /// </summary> /// <param name="value">The <see cref="lkpBitRow"/> /// object used to update the table record.</param> /// <returns>true if the record was updated; otherwise, false.</returns> public virtual bool Update(lkpBitRow value) { IDbCommand cmd = _db.CreateCommand("dbo._lkpBit_Update", true); AddParameter(cmd, "BitName", value.BitName); AddParameter(cmd, "BitID", value.BitID); return(0 != cmd.ExecuteNonQuery()); }
/// <summary> /// Adds a new record into the <c>lkpBit</c> table. /// </summary> /// <param name="value">The <see cref="lkpBitRow"/> object to be inserted.</param> public virtual void Insert(lkpBitRow value) { IDbCommand cmd = _db.CreateCommand("dbo._lkpBit_Insert", true); AddParameter(cmd, "BitID", value.BitID); AddParameter(cmd, "BitName", value.BitName); 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="lkpBitRow"/> objects.</returns> protected virtual lkpBitRow[] 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 bitIDColumnIndex = reader.GetOrdinal("BitID"); int bitNameColumnIndex = reader.GetOrdinal("BitName"); System.Collections.ArrayList recordList = new System.Collections.ArrayList(); int ri = -startIndex; while (reader.Read()) { ri++; if (ri > 0 && ri <= length) { lkpBitRow record = new lkpBitRow(); recordList.Add(record); record.BitID = Convert.ToInt32(reader.GetValue(bitIDColumnIndex)); if (!reader.IsDBNull(bitNameColumnIndex)) { record.BitName = Convert.ToString(reader.GetValue(bitNameColumnIndex)); } if (ri == length && 0 != totalRecordCount) { break; } } } totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1; return((lkpBitRow[])(recordList.ToArray(typeof(lkpBitRow)))); }
/// <summary> /// Converts <see cref="System.Data.DataRow"/> to <see cref="lkpBitRow"/>. /// </summary> /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param> /// <returns>A reference to the <see cref="lkpBitRow"/> object.</returns> protected virtual lkpBitRow MapRow(DataRow row) { lkpBitRow mappedObject = new lkpBitRow(); DataTable dataTable = row.Table; DataColumn dataColumn; // Column "BitID" dataColumn = dataTable.Columns["BitID"]; if (!row.IsNull(dataColumn)) { mappedObject.BitID = (int)row[dataColumn]; } // Column "BitName" dataColumn = dataTable.Columns["BitName"]; if (!row.IsNull(dataColumn)) { mappedObject.BitName = (string)row[dataColumn]; } return(mappedObject); }
/// <summary> /// Deletes the specified object from the <c>lkpBit</c> table. /// </summary> /// <param name="value">The <see cref="lkpBitRow"/> object to delete.</param> /// <returns>true if the record was deleted; otherwise, false.</returns> public bool Delete(lkpBitRow value) { return(DeleteByPrimaryKey(value.BitID)); }