/// <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 view.</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="TerminationRouteViewRow"/> objects.</returns>
        protected virtual TerminationRouteViewRow[] 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 carrier_route_idColumnIndex  = reader.GetOrdinal("carrier_route_id");
            int route_nameColumnIndex        = reader.GetOrdinal("route_name");
            int carrier_acct_idColumnIndex   = reader.GetOrdinal("carrier_acct_id");
            int carrier_acct_nameColumnIndex = reader.GetOrdinal("carrier_acct_name");
            int calling_plan_idColumnIndex   = reader.GetOrdinal("calling_plan_id");
            int rating_typeColumnIndex       = reader.GetOrdinal("rating_type");
            int base_route_idColumnIndex     = reader.GetOrdinal("base_route_id");
            int partial_coverageColumnIndex  = reader.GetOrdinal("partial_coverage");

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

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

                    record.Carrier_route_id = Convert.ToInt32(reader.GetValue(carrier_route_idColumnIndex));
                    record.Route_name       = Convert.ToString(reader.GetValue(route_nameColumnIndex));
                    if (!reader.IsDBNull(carrier_acct_idColumnIndex))
                    {
                        record.Carrier_acct_id = Convert.ToInt16(reader.GetValue(carrier_acct_idColumnIndex));
                    }
                    record.Carrier_acct_name = Convert.ToString(reader.GetValue(carrier_acct_nameColumnIndex));
                    record.Calling_plan_id   = Convert.ToInt32(reader.GetValue(calling_plan_idColumnIndex));
                    if (!reader.IsDBNull(rating_typeColumnIndex))
                    {
                        record.Rating_type = Convert.ToByte(reader.GetValue(rating_typeColumnIndex));
                    }
                    record.Base_route_id = Convert.ToInt32(reader.GetValue(base_route_idColumnIndex));
                    if (!reader.IsDBNull(partial_coverageColumnIndex))
                    {
                        record.Partial_coverage = Convert.ToByte(reader.GetValue(partial_coverageColumnIndex));
                    }

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

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

            // Column "Carrier_route_id"
            dataColumn = dataTable.Columns["Carrier_route_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Carrier_route_id = (int)row[dataColumn];
            }
            // Column "Route_name"
            dataColumn = dataTable.Columns["Route_name"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Route_name = (string)row[dataColumn];
            }
            // Column "Carrier_acct_id"
            dataColumn = dataTable.Columns["Carrier_acct_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Carrier_acct_id = (short)row[dataColumn];
            }
            // Column "Carrier_acct_name"
            dataColumn = dataTable.Columns["Carrier_acct_name"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Carrier_acct_name = (string)row[dataColumn];
            }
            // Column "Calling_plan_id"
            dataColumn = dataTable.Columns["Calling_plan_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Calling_plan_id = (int)row[dataColumn];
            }
            // Column "Rating_type"
            dataColumn = dataTable.Columns["Rating_type"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Rating_type = (byte)row[dataColumn];
            }
            // Column "Base_route_id"
            dataColumn = dataTable.Columns["Base_route_id"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Base_route_id = (int)row[dataColumn];
            }
            // Column "Partial_coverage"
            dataColumn = dataTable.Columns["Partial_coverage"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Partial_coverage = (byte)row[dataColumn];
            }
            return(mappedObject);
        }