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