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

            // Column "Rate_info_id"
            dataColumn = dataTable.Columns["Rate_info_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Rate_info_id = (int)row[dataColumn];
            }
            // Column "Type_of_day_choice"
            dataColumn = dataTable.Columns["Type_of_day_choice"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Type_of_day_choice = (byte)row[dataColumn];
            }
            // Column "Time_of_day_policy"
            dataColumn = dataTable.Columns["Time_of_day_policy"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Time_of_day_policy = (byte)row[dataColumn];
            }
            return(mappedObject);
        }
        /// <summary>
        /// Updates a record in the <c>TypeOfDay</c> table.
        /// </summary>
        /// <param name="value">The <see cref="TypeOfDayRow"/>
        /// object used to update the table record.</param>
        /// <returns>true if the record was updated; otherwise, false.</returns>
        public virtual bool Update(TypeOfDayRow value)
        {
            string sqlStr = "UPDATE [dbo].[TypeOfDay] SET " +
                            "[time_of_day_policy]=" + _db.CreateSqlParameterName("Time_of_day_policy") +
                            " WHERE " +
                            "[rate_info_id]=" + _db.CreateSqlParameterName("Rate_info_id") + " AND " +
                            "[type_of_day_choice]=" + _db.CreateSqlParameterName("Type_of_day_choice");
            IDbCommand cmd = _db.CreateCommand(sqlStr);

            AddParameter(cmd, "Time_of_day_policy", value.Time_of_day_policy);
            AddParameter(cmd, "Rate_info_id", value.Rate_info_id);
            AddParameter(cmd, "Type_of_day_choice", value.Type_of_day_choice);
            return(0 != cmd.ExecuteNonQuery());
        }
        /// <summary>
        /// Adds a new record into the <c>TypeOfDay</c> table.
        /// </summary>
        /// <param name="value">The <see cref="TypeOfDayRow"/> object to be inserted.</param>
        public virtual void Insert(TypeOfDayRow value)
        {
            string sqlStr = "INSERT INTO [dbo].[TypeOfDay] (" +
                            "[rate_info_id], " +
                            "[type_of_day_choice], " +
                            "[time_of_day_policy]" +
                            ") VALUES (" +
                            _db.CreateSqlParameterName("Rate_info_id") + ", " +
                            _db.CreateSqlParameterName("Type_of_day_choice") + ", " +
                            _db.CreateSqlParameterName("Time_of_day_policy") + ")";
            IDbCommand cmd = _db.CreateCommand(sqlStr);

            AddParameter(cmd, "Rate_info_id", value.Rate_info_id);
            AddParameter(cmd, "Type_of_day_choice", value.Type_of_day_choice);
            AddParameter(cmd, "Time_of_day_policy", value.Time_of_day_policy);
            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="TypeOfDayRow"/> objects.</returns>
        protected virtual TypeOfDayRow[] 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 rate_info_idColumnIndex       = reader.GetOrdinal("rate_info_id");
            int type_of_day_choiceColumnIndex = reader.GetOrdinal("type_of_day_choice");
            int time_of_day_policyColumnIndex = reader.GetOrdinal("time_of_day_policy");

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

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

                    record.Rate_info_id       = Convert.ToInt32(reader.GetValue(rate_info_idColumnIndex));
                    record.Type_of_day_choice = Convert.ToByte(reader.GetValue(type_of_day_choiceColumnIndex));
                    record.Time_of_day_policy = Convert.ToByte(reader.GetValue(time_of_day_policyColumnIndex));

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

            totalRecordCount = 0 == totalRecordCount ? ri + startIndex : -1;
            return((TypeOfDayRow[])(recordList.ToArray(typeof(TypeOfDayRow))));
        }
 /// <summary>
 /// Deletes the specified object from the <c>TypeOfDay</c> table.
 /// </summary>
 /// <param name="value">The <see cref="TypeOfDayRow"/> object to delete.</param>
 /// <returns>true if the record was deleted; otherwise, false.</returns>
 public bool Delete(TypeOfDayRow value)
 {
     return(DeleteByPrimaryKey(value.Rate_info_id, value.Type_of_day_choice));
 }