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