Table of Contents

PaginationEnumerable<T> Class

Definition

Represents a generic and read-only pagination sequence.

public class PaginationEnumerable<T> : IEnumerable<T>, IEnumerable

Type Parameters

T

The type of elements in the collection.

Inheritance
PaginationEnumerable<T>
Implements
Derived

Examples

The following example demonstrates lazy pagination of a string array using PaginationEnumerable. It shows how to access page 2 with 3 items per page and prints page metadata such as page count and navigation flags.

using System;
using System.Collections.Generic;
using System.Linq;
using Cuemon.Collections.Generic;

namespace MyApp.Examples
{
    public class PaginationEnumerableExample
    {
        public static void Demonstrate()
        {
            var fruits = new[] { "Apple", "Banana", "Cherry", "Date", "Elderberry", "Fig", "Grape", "Honeydew" };

            // Show page 2 with 3 items per page
            var page = new PaginationEnumerable<string>(fruits, () => fruits.Length, setup =>
            {
                setup.PageSize = 3;
                setup.PageNumber = 2;
            });

            Console.WriteLine($"Page {2} of {page.PageCount} (total items: {page.TotalElementCount})");
            Console.WriteLine($"Has previous page: {page.HasPreviousPage}");
            Console.WriteLine($"Has next page: {page.HasNextPage}");
            Console.WriteLine("Items on this page:");
            foreach (var item in page)
            {
                Console.WriteLine($"  {item}");

}}}
}

Constructors

Name Description
PaginationEnumerable(IEnumerable<T>, Func<int>, Action<PaginationOptions>)

Initializes a new instance of the PaginationEnumerable<T> class.

Properties

Name Description
FirstPage

Gets a value indicating whether this instance is on the first paged data sequence.

HasNextPage

Gets a value indicating whether this instance has a next paged data sequence.

HasPreviousPage

Gets a value indicating whether this instance has a previous paged data sequence.

LastPage

Gets a value indicating whether this instance is on the last paged data sequence.

PageCount

Gets the total amount of pages for the elements in this sequence.

PageSource

Gets the page source of this instance.

TotalElementCount

Gets the total number of elements in the sequence before paging is applied.

Methods

Name Description
GetEnumerator()

Returns an enumerator that iterates through the collection.

See Also