/// <summary> /// Converts <see cref="System.Data.DataRow"/> to <see cref="lkpCandidateRow"/>. /// </summary> /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param> /// <returns>A reference to the <see cref="lkpCandidateRow"/> object.</returns> protected virtual lkpCandidateRow MapRow(DataRow row) { lkpCandidateRow mappedObject = new lkpCandidateRow(); DataTable dataTable = row.Table; DataColumn dataColumn; // Column "Cand_ID" dataColumn = dataTable.Columns["Cand_ID"]; if (!row.IsNull(dataColumn)) { mappedObject.Cand_ID = (int)row[dataColumn]; } // Column "Cand_No" dataColumn = dataTable.Columns["Cand_No"]; if (!row.IsNull(dataColumn)) { mappedObject.Cand_No = (string)row[dataColumn]; } // Column "Cand_Name" dataColumn = dataTable.Columns["Cand_Name"]; if (!row.IsNull(dataColumn)) { mappedObject.Cand_Name = (string)row[dataColumn]; } // Column "Cand_FName" dataColumn = dataTable.Columns["Cand_FName"]; if (!row.IsNull(dataColumn)) { mappedObject.Cand_FName = (string)row[dataColumn]; } // Column "GenderID" dataColumn = dataTable.Columns["GenderID"]; if (!row.IsNull(dataColumn)) { mappedObject.GenderID = (int)row[dataColumn]; } // Column "Prov_ID" dataColumn = dataTable.Columns["Prov_ID"]; if (!row.IsNull(dataColumn)) { mappedObject.Prov_ID = (int)row[dataColumn]; } // Column "IsDeleted" dataColumn = dataTable.Columns["IsDeleted"]; if (!row.IsNull(dataColumn)) { mappedObject.IsDeleted = (bool)row[dataColumn]; } return(mappedObject); }
/// <summary> /// Adds a new record into the <c>lkpCandidate</c> table. /// </summary> /// <param name="value">The <see cref="lkpCandidateRow"/> object to be inserted.</param> public virtual void Insert(lkpCandidateRow value) { IDbCommand cmd = _db.CreateCommand("dbo._lkpCandidate_Insert", true); AddParameter(cmd, "Cand_No", value.Cand_No); AddParameter(cmd, "Cand_Name", value.Cand_Name); AddParameter(cmd, "Cand_FName", value.Cand_FName); AddParameter(cmd, "GenderID", value.IsGenderIDNull ? DBNull.Value : (object)value.GenderID); AddParameter(cmd, "Prov_ID", value.IsProv_IDNull ? DBNull.Value : (object)value.Prov_ID); AddParameter(cmd, "IsDeleted", value.IsIsDeletedNull ? DBNull.Value : (object)value.IsDeleted); value.Cand_ID = Convert.ToInt32(cmd.ExecuteScalar()); }
/// <summary> /// Updates a record in the <c>lkpCandidate</c> table. /// </summary> /// <param name="value">The <see cref="lkpCandidateRow"/> /// object used to update the table record.</param> /// <returns>true if the record was updated; otherwise, false.</returns> public virtual bool Update(lkpCandidateRow value) { IDbCommand cmd = _db.CreateCommand("dbo._lkpCandidate_Update", true); AddParameter(cmd, "Cand_No", value.Cand_No); AddParameter(cmd, "Cand_Name", value.Cand_Name); AddParameter(cmd, "Cand_FName", value.Cand_FName); AddParameter(cmd, "GenderID", value.IsGenderIDNull ? DBNull.Value : (object)value.GenderID); AddParameter(cmd, "Prov_ID", value.IsProv_IDNull ? DBNull.Value : (object)value.Prov_ID); AddParameter(cmd, "IsDeleted", value.IsIsDeletedNull ? DBNull.Value : (object)value.IsDeleted); AddParameter(cmd, "Cand_ID", value.Cand_ID); return(0 != 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="lkpCandidateRow"/> objects.</returns> protected virtual lkpCandidateRow[] 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 cand_IDColumnIndex = reader.GetOrdinal("Cand_ID"); int cand_NoColumnIndex = reader.GetOrdinal("Cand_No"); int cand_NameColumnIndex = reader.GetOrdinal("Cand_Name"); int cand_FNameColumnIndex = reader.GetOrdinal("Cand_FName"); int genderIDColumnIndex = reader.GetOrdinal("GenderID"); int prov_IDColumnIndex = reader.GetOrdinal("Prov_ID"); int isDeletedColumnIndex = reader.GetOrdinal("IsDeleted"); System.Collections.ArrayList recordList = new System.Collections.ArrayList(); int ri = -startIndex; while (reader.Read()) { ri++; if (ri > 0 && ri <= length) { lkpCandidateRow record = new lkpCandidateRow(); recordList.Add(record); record.Cand_ID = Convert.ToInt32(reader.GetValue(cand_IDColumnIndex)); if (!reader.IsDBNull(cand_NoColumnIndex)) { record.Cand_No = Convert.ToString(reader.GetValue(cand_NoColumnIndex)); } if (!reader.IsDBNull(cand_NameColumnIndex)) { record.Cand_Name = Convert.ToString(reader.GetValue(cand_NameColumnIndex)); } if (!reader.IsDBNull(cand_FNameColumnIndex)) { record.Cand_FName = Convert.ToString(reader.GetValue(cand_FNameColumnIndex)); } if (!reader.IsDBNull(genderIDColumnIndex)) { record.GenderID = Convert.ToInt32(reader.GetValue(genderIDColumnIndex)); } if (!reader.IsDBNull(prov_IDColumnIndex)) { record.Prov_ID = Convert.ToInt32(reader.GetValue(prov_IDColumnIndex)); } if (!reader.IsDBNull(isDeletedColumnIndex)) { record.IsDeleted = Convert.ToBoolean(reader.GetValue(isDeletedColumnIndex)); } if (ri == length && 0 != totalRecordCount) { break; } } } totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1; return((lkpCandidateRow[])(recordList.ToArray(typeof(lkpCandidateRow)))); }
/// <summary> /// Deletes the specified object from the <c>lkpCandidate</c> table. /// </summary> /// <param name="value">The <see cref="lkpCandidateRow"/> object to delete.</param> /// <returns>true if the record was deleted; otherwise, false.</returns> public bool Delete(lkpCandidateRow value) { return(DeleteByPrimaryKey(value.Cand_ID)); }