/// <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="ThreadDetailsRow"/> objects.</returns>
        protected virtual ThreadDetailsRow[] 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 news_IDColumnIndex          = reader.GetOrdinal("News_ID");
            int news_TitleColumnIndex       = reader.GetOrdinal("News_Title");
            int threaddetails_IDColumnIndex = reader.GetOrdinal("Threaddetails_ID");
            int titleColumnIndex            = reader.GetOrdinal("Title");
            int thread_IDColumnIndex        = reader.GetOrdinal("Thread_ID");

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

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

                    record.News_ID = Convert.ToInt64(reader.GetValue(news_IDColumnIndex));
                    if (!reader.IsDBNull(news_TitleColumnIndex))
                    {
                        record.News_Title = Convert.ToString(reader.GetValue(news_TitleColumnIndex));
                    }
                    record.Threaddetails_ID = Convert.ToInt32(reader.GetValue(threaddetails_IDColumnIndex));
                    record.Title            = Convert.ToString(reader.GetValue(titleColumnIndex));
                    record.Thread_ID        = Convert.ToInt32(reader.GetValue(thread_IDColumnIndex));

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

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

            // Column "News_ID"
            dataColumn = dataTable.Columns["News_ID"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.News_ID = (long)row[dataColumn];
            }
            // Column "News_Title"
            dataColumn = dataTable.Columns["News_Title"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.News_Title = (string)row[dataColumn];
            }
            // Column "Threaddetails_ID"
            dataColumn = dataTable.Columns["Threaddetails_ID"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Threaddetails_ID = (int)row[dataColumn];
            }
            // Column "Title"
            dataColumn = dataTable.Columns["Title"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Title = (string)row[dataColumn];
            }
            // Column "Thread_ID"
            dataColumn = dataTable.Columns["Thread_ID"];
            if (!row.IsNull(dataColumn))
            {
                mappedObject.Thread_ID = (int)row[dataColumn];
            }
            return(mappedObject);
        }