Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4017712
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:53:41+00:00 2026-05-20T09:53:41+00:00

Using a paged result of some query i need to get from what page

  • 0

Using a paged result of some query i need to get from what page is a point.The object is return the data positioned at the right page when you push the point out of the scope opening the paged result at this page.
If the paged result can be obtain like this sample , how i can get from an item from what page is comming ?

paging
.skip(PAGE_SIZE * (PAGE_NUMBER - 1)).limit(PAGE_SIZE)

    public List<BsonItem> GetData(QueryComplete query, int take, int skip, SortByBuilder sort)
        {
            var cursor = Db.Data.FindAs<BsonItem>(query);

            if (skip > 0)
                cursor.SetSkip(skip);
            if (take > 0)
                cursor.SetLimit(take);
            if (sort != null )
                cursor.SetSortOrder(sort);
            return cursor.ToList();
        }

Thanks for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T09:53:42+00:00Added an answer on May 20, 2026 at 9:53 am

    Page number should( and possible sort order and direction) come from the client side. So client click on the some page and than..

    Personally i using some kind of filter that contains all properties that you need.

    Using that filter you just need to specify page that you need to display in grid and how much items you need per page.

    var pageNumber = 1;// current page should come from the client
    var filter = new BaseFilter(){CurrentPage = pageNumber, ItemsPerPage = 30};
    var items = GetItemsByFilter(filter, Query.LTE("SomeDate",DateTime.Now)),
                                         SortBy.Ascending("SortField"));
    //For basic paging you only following three properties
    var totalCount = filter.TotalCount; // here will be total items count
    var pagesCount = filter.TotalPagesCount; // here will be total pages count
    // pageNumber  = current page
    

    Also you can inferit from BasicFilter and add any properties that you need for quering, sorting.
    Here filter code(hope it will be useful for you):

     public List<Item> GetItemsByFilter(BaseFilter filter, 
                       QueryComplete query, SortByBuilder sort)
     {
       var resultItems = new List<Item>();
       var cursor = Db.Data.FindAs<BsonItem>(query);
    
       cursor.SetSortOrder(sort);
       if (filter.IsNeedPaging)
       {
         cursor.SetSkip(filter.Skip).SetLimit(filter.Take);
         filter.TotalCount = cursor.Count();
       }
    
       resultItems.AddRange(cursor);
    
       return resultItems;
     }
    
    
     public class BaseFilter
     {
       private int _itemsPerPage = 10;
       private int _skip = 0;
       private int _currentPage = 1;
    
       public BaseFilter()
       {
         IsNeedPaging = true;
       }
    
       public int Skip
       {
         get
         {
           if (_skip == 0)
             _skip = (CurrentPage - 1) * _itemsPerPage;
           return _skip;
         }
         set
         {
           _skip = value;
         }
       }
    
       public int Take
       {
         get
          {
             return _itemsPerPage;
          }
         set
          {
            _itemsPerPage = value;
          }
        }
    
        public bool IsNeedPaging { get; set; }
    
        public int TotalCount { get; set; }
    
        public int CurrentPage
        {
          get
            {
               return _currentPage;
            }
          set
            {
              _currentPage = value;
            }
        }
    
        public int ItemsPerPage
        {
          get
            {
              return _itemsPerPage;
            }
          set
            {
              _itemsPerPage = value;
            }
         }
    
         public int TotalPagesCount
         {
           get
             {
               return TotalCount / ItemsPerPage + 
                                ((TotalCount % ItemsPerPage > 0) ? 1 : 0);
             }
         }
       }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using SQL Server 2008 and the following query to implement paged data retrieval
Often I need to combine data from multiple tables and display the result in
I need to access some data from an MS Access database and retrieve some
I am storing some JSON data in a text file to query using jQuery
I have a php page that pulls data from a mysql database based on
I really need some help about how to pass returndate value in next page(save.php).
Using a Java-based back-end (i.e., servlets and JSP), if I need the contextPath from
using a drop-down list that's populated from database fields, i need to select an
I'm trying to get insights from facebook for some pages I have admin rights
I'm using LINQ to Entities to display paged results. But I'm having issues with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.