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

Are there any built in functions that do unix time stamp comparisons in php?
Is there any built-in way to reproduce the behaviour showed on the Office app,
Is there any built-in way to apply the fixups that JABSORB generates using json
is there any built in functionality (flag, parameter, whatever..) to send a TCP packet
Is there any built in way to get a users email address based on
Isn't there any built in class in PHP that has HashTable in PHP? If
i've a string like 1.00E+4 Is there any built in function to convert this
Had a look over SO but I can't see any threads which address my
I'm trying to achieve this effect with jQuery. I wrote some of the code,
I have a master project that's using a fairly standard source tree approach +

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.