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

            // Column "Time_of_day"
            dataColumn = dataTable.Columns["Time_of_day"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Time_of_day = (byte)row[dataColumn];
            }
            // Column "Name"
            dataColumn = dataTable.Columns["Name"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Name = (string)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>TimeOfDay</c> table.
        /// </summary>
        /// <param name="value">The <see cref="TimeOfDayRow"/>
        /// object used to update the table record.</param>
        /// <returns>true if the record was updated; otherwise, false.</returns>
        public virtual bool Update(TimeOfDayRow value)
        {
            string sqlStr = "UPDATE [dbo].[TimeOfDay] SET " +
                            "[name]=" + _db.CreateSqlParameterName("Name") + ", " +
                            "[time_of_day_policy]=" + _db.CreateSqlParameterName("Time_of_day_policy") +
                            " WHERE " +
                            "[time_of_day]=" + _db.CreateSqlParameterName("Time_of_day");
            IDbCommand cmd = _db.CreateCommand(sqlStr);

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

            AddParameter(cmd, "Time_of_day", value.Time_of_day);
            AddParameter(cmd, "Name", value.Name);
            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="TimeOfDayRow"/> objects.</returns>
        protected virtual TimeOfDayRow[] 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 time_of_dayColumnIndex        = reader.GetOrdinal("time_of_day");
            int nameColumnIndex               = reader.GetOrdinal("name");
            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)
                {
                    TimeOfDayRow record = new TimeOfDayRow();
                    recordList.Add(record);

                    record.Time_of_day        = Convert.ToByte(reader.GetValue(time_of_dayColumnIndex));
                    record.Name               = Convert.ToString(reader.GetValue(nameColumnIndex));
                    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((TimeOfDayRow[])(recordList.ToArray(typeof(TimeOfDayRow))));
        }
 /// <summary>
 /// Deletes the specified object from the <c>TimeOfDay</c> table.
 /// </summary>
 /// <param name="value">The <see cref="TimeOfDayRow"/> object to delete.</param>
 /// <returns>true if the record was deleted; otherwise, false.</returns>
 public bool Delete(TimeOfDayRow value)
 {
     return(DeleteByPrimaryKey(value.Time_of_day));
 }