/// <summary>
        /// Converts <see cref="System.Data.DataRow"/> to <see cref="lkpAllegationtypeRow"/>.
        /// </summary>
        /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param>
        /// <returns>A reference to the <see cref="lkpAllegationtypeRow"/> object.</returns>
        protected virtual lkpAllegationtypeRow MapRow(DataRow row)
        {
            lkpAllegationtypeRow mappedObject = new lkpAllegationtypeRow();
            DataTable            dataTable    = row.Table;
            DataColumn           dataColumn;

            // Column "AllagType_ID"
            dataColumn = dataTable.Columns["AllagType_ID"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.AllagType_ID = (int)row[dataColumn];
            }
            // Column "AllagType_Name"
            dataColumn = dataTable.Columns["AllagType_Name"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.AllagType_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>lkpAllegationtype</c> table.
        /// </summary>
        /// <param name="value">The <see cref="lkpAllegationtypeRow"/>
        /// object used to update the table record.</param>
        /// <returns>true if the record was updated; otherwise, false.</returns>
        public virtual bool Update(lkpAllegationtypeRow value)
        {
            IDbCommand cmd = _db.CreateCommand("dbo._lkpAllegationtype_Update", true);

            AddParameter(cmd, "AllagType_Name", value.AllagType_Name);
            AddParameter(cmd, "Active",
                         value.IsActiveNull ? DBNull.Value : (object)value.Active);
            AddParameter(cmd, "AllagType_ID", value.AllagType_ID);
            return(0 != cmd.ExecuteNonQuery());
        }
        /// <summary>
        /// Adds a new record into the <c>lkpAllegationtype</c> table.
        /// </summary>
        /// <param name="value">The <see cref="lkpAllegationtypeRow"/> object to be inserted.</param>
        public virtual void Insert(lkpAllegationtypeRow value)
        {
            IDbCommand cmd = _db.CreateCommand("dbo._lkpAllegationtype_Insert", true);

            AddParameter(cmd, "AllagType_ID", value.AllagType_ID);
            AddParameter(cmd, "AllagType_Name", value.AllagType_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="lkpAllegationtypeRow"/> objects.</returns>
        protected virtual lkpAllegationtypeRow[] 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 allagType_IDColumnIndex   = reader.GetOrdinal("AllagType_ID");
            int allagType_NameColumnIndex = reader.GetOrdinal("AllagType_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)
                {
                    lkpAllegationtypeRow record = new lkpAllegationtypeRow();
                    recordList.Add(record);

                    record.AllagType_ID = Convert.ToInt32(reader.GetValue(allagType_IDColumnIndex));
                    if (!reader.IsDBNull(allagType_NameColumnIndex))
                    {
                        record.AllagType_Name = Convert.ToString(reader.GetValue(allagType_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((lkpAllegationtypeRow[])(recordList.ToArray(typeof(lkpAllegationtypeRow))));
        }
 /// <summary>
 /// Deletes the specified object from the <c>lkpAllegationtype</c> table.
 /// </summary>
 /// <param name="value">The <see cref="lkpAllegationtypeRow"/> object to delete.</param>
 /// <returns>true if the record was deleted; otherwise, false.</returns>
 public bool Delete(lkpAllegationtypeRow value)
 {
     return(DeleteByPrimaryKey(value.AllagType_ID));
 }