/// <summary>
        /// Updates a record in the <c>lkpDistrict</c> table.
        /// </summary>
        /// <param name="value">The <see cref="lkpDistrictRow"/>
        /// object used to update the table record.</param>
        /// <returns>true if the record was updated; otherwise, false.</returns>
        public virtual bool Update(lkpDistrictRow value)
        {
            IDbCommand cmd = _db.CreateCommand("dbo._lkpDistrict_Update", true);

            AddParameter(cmd, "District_Name", value.District_Name);
            AddParameter(cmd, "District_Dari", value.District_Dari);
            AddParameter(cmd, "District_Code", value.District_Code);
            AddParameter(cmd, "Province_Id",
                         value.IsProvince_IdNull ? DBNull.Value : (object)value.Province_Id);
            AddParameter(cmd, "District_Id", value.District_Id);
            return(0 != cmd.ExecuteNonQuery());
        }
        /// <summary>
        /// Adds a new record into the <c>lkpDistrict</c> table.
        /// </summary>
        /// <param name="value">The <see cref="lkpDistrictRow"/> object to be inserted.</param>
        public virtual void Insert(lkpDistrictRow value)
        {
            IDbCommand cmd = _db.CreateCommand("dbo._lkpDistrict_Insert", true);

            AddParameter(cmd, "District_Id", value.District_Id);
            AddParameter(cmd, "District_Name", value.District_Name);
            AddParameter(cmd, "District_Dari", value.District_Dari);
            AddParameter(cmd, "District_Code", value.District_Code);
            AddParameter(cmd, "Province_Id",
                         value.IsProvince_IdNull ? DBNull.Value : (object)value.Province_Id);
            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="lkpDistrictRow"/> objects.</returns>
        protected virtual lkpDistrictRow[] 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 district_IdColumnIndex   = reader.GetOrdinal("District_Id");
            int district_NameColumnIndex = reader.GetOrdinal("District_Name");
            int district_DariColumnIndex = reader.GetOrdinal("District_Dari");
            int district_CodeColumnIndex = reader.GetOrdinal("District_Code");
            int province_IdColumnIndex   = reader.GetOrdinal("Province_Id");

            System.Collections.ArrayList recordList = new System.Collections.ArrayList();
            int ri = -startIndex;

            while (reader.Read())
            {
                ri++;
                if (ri > 0 && ri <= length)
                {
                    lkpDistrictRow record = new lkpDistrictRow();
                    recordList.Add(record);

                    record.District_Id   = Convert.ToInt32(reader.GetValue(district_IdColumnIndex));
                    record.District_Name = Convert.ToString(reader.GetValue(district_NameColumnIndex));
                    record.District_Dari = Convert.ToString(reader.GetValue(district_DariColumnIndex));
                    if (!reader.IsDBNull(district_CodeColumnIndex))
                    {
                        record.District_Code = Convert.ToString(reader.GetValue(district_CodeColumnIndex));
                    }
                    if (!reader.IsDBNull(province_IdColumnIndex))
                    {
                        record.Province_Id = Convert.ToInt32(reader.GetValue(province_IdColumnIndex));
                    }

                    if (ri == length && 0 != totalRecordCount)
                    {
                        break;
                    }
                }
            }

            totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1;
            return((lkpDistrictRow[])(recordList.ToArray(typeof(lkpDistrictRow))));
        }
        /// <summary>
        /// Converts <see cref="System.Data.DataRow"/> to <see cref="lkpDistrictRow"/>.
        /// </summary>
        /// <param name="row">The <see cref="System.Data.DataRow"/> object to be mapped.</param>
        /// <returns>A reference to the <see cref="lkpDistrictRow"/> object.</returns>
        protected virtual lkpDistrictRow MapRow(DataRow row)
        {
            lkpDistrictRow mappedObject = new lkpDistrictRow();
            DataTable      dataTable    = row.Table;
            DataColumn     dataColumn;

            // Column "District_Id"
            dataColumn = dataTable.Columns["District_Id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.District_Id = (int)row[dataColumn];
            }
            // Column "District_Name"
            dataColumn = dataTable.Columns["District_Name"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.District_Name = (string)row[dataColumn];
            }
            // Column "District_Dari"
            dataColumn = dataTable.Columns["District_Dari"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.District_Dari = (string)row[dataColumn];
            }
            // Column "District_Code"
            dataColumn = dataTable.Columns["District_Code"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.District_Code = (string)row[dataColumn];
            }
            // Column "Province_Id"
            dataColumn = dataTable.Columns["Province_Id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Province_Id = (int)row[dataColumn];
            }
            return(mappedObject);
        }
 /// <summary>
 /// Deletes the specified object from the <c>lkpDistrict</c> table.
 /// </summary>
 /// <param name="value">The <see cref="lkpDistrictRow"/> object to delete.</param>
 /// <returns>true if the record was deleted; otherwise, false.</returns>
 public bool Delete(lkpDistrictRow value)
 {
     return(DeleteByPrimaryKey(value.District_Id));
 }