Exemplo n.º 1
0
        /// <summary>
        /// Calculates record and page count for the specified query
        /// </summary>
        private VirtualRecordCount CalculateVirtualRecordCount()
        {
            var count = new VirtualRecordCount
            {
                RecordCount       = IsQueryTotalCount ? GetQueryVirtualCount() : TotalCount,
                RecordsInLastPage = ItemsPerPage
            };

            // Calculate the virtual number of records from the query

            // Calculate the correspondent number of pages
            var lastPage  = count.RecordCount / ItemsPerPage;
            var remainder = count.RecordCount % ItemsPerPage;

            if (remainder > 0)
            {
                lastPage++;
            }
            count.PageCount = lastPage;

            // Calculate the number of items in the last page
            if (remainder > 0)
            {
                count.RecordsInLastPage = remainder;
            }
            return(count);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Prepares and returns the command object for the reader-based query
        /// </summary>
        private string PrepareCommand(VirtualRecordCount countInfo)
        {
            // Determines how many records are to be retrieved.
            // The last page could require less than other pages
            var recsToRetrieve = ItemsPerPage;

            if (CurrentPageIndex == countInfo.PageCount - 1)
            {
                recsToRetrieve = countInfo.RecordsInLastPage;
            }

            return(GetQueryPageCommandText(recsToRetrieve));
        }