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 655005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:33:22+00:00 2026-05-13T22:33:22+00:00

Are there any built in paging functions for IEnumberable (or a better library to

  • 0

Are there any built in paging functions for IEnumberable (or a better library to use)? I know there is Take<>(), but I find myself repeatedly implementing the basic calculations to determine # of pages for a given page size. I realize it’s simple implementation, but that’s why I’m hoping it’s already in the library and I just missed it.

By paging I mean a pointer to current record and something to fulfill the following concepts.

.PageSize <- get/set page size
.Last <- last page
.Current <- current page
.JumpTo(pageNumber)

With the fail safes to make sure you end up in the right place if page size or set size change

  • 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-13T22:33:22+00:00Added an answer on May 13, 2026 at 10:33 pm

    You can use the PagedList wrapper around a List by Rob Conery. There is also an extended version by Troy Goode.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    
    namespace System.Web.Mvc
    {
        public interface IPagedList
        {
            int TotalCount
            {
                get;
                set;
            }
    
            int PageIndex
            {
                get;
                set;
            }
    
            int PageSize
            {
                get;
                set;
            }
    
            bool IsPreviousPage
            {
                get;
            }
    
            bool IsNextPage
            {
                get;
            }     
        }
    
        public class PagedList<T> : List<T>, IPagedList
        {
            public PagedList(IQueryable<T> source, int index, int pageSize)
            {
                this.TotalCount = source.Count();
                this.PageSize = pageSize;
                this.PageIndex = index;
                this.AddRange(source.Skip(index * pageSize).Take(pageSize).ToList());
            }    
    
            public PagedList(List<T> source, int index, int pageSize)
            {
                this.TotalCount = source.Count();
                this.PageSize = pageSize;
                this.PageIndex = index;
                this.AddRange(source.Skip(index * pageSize).Take(pageSize).ToList());
            }
    
            public int TotalCount      
            { 
                get; set; 
            }
    
            public int PageIndex       
            { 
                get; set; 
            }
    
            public int PageSize 
            { 
                get; set; 
            }
    
            public bool IsPreviousPage 
            { 
                get 
                {
                    return (PageIndex > 0);
                }
            }
    
            public bool IsNextPage 
            { 
                get
                {
                    return (PageIndex * PageSize) <=TotalCount;
                } 
            }        
        }
    
        public static class Pagination
        {
            public static PagedList<T> ToPagedList<T>(this IQueryable<T> source, int index, int pageSize) 
            {
                return new PagedList<T>(source, index, pageSize);
            }
    
            public static PagedList<T> ToPagedList<T>(this IQueryable<T> source, int index)
            {
                return new PagedList<T>(source, index, 10);
            }        
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any built in method that would combine the functions of Enumerable.select (find
Is there any built in library that I can use for calculating median in
Is there any built-in, or library-provided way to map a set of variadic template
Are there any built in functions for SQL where I can pass in a
Is there any built-in functions in MATLAB that would statistically extend a sequence of
Are there any built in functions that do unix time stamp comparisons in php?
Are there any built-in functions that allow elementwise operations over tuples in Python 3?
Is there any built in library for sliding a window (custom size) over an
Are there any built-in C# data structures that are like a hash table but
Is there any built-in way to use Roslyn to perform the same compile-time transformations

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.