QDev.CSharp.Pagination.PaginatedList 1.0.1

dotnet add package QDev.CSharp.Pagination.PaginatedList --version 1.0.1
NuGet\Install-Package QDev.CSharp.Pagination.PaginatedList -Version 1.0.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="QDev.CSharp.Pagination.PaginatedList" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add QDev.CSharp.Pagination.PaginatedList --version 1.0.1
#r "nuget: QDev.CSharp.Pagination.PaginatedList, 1.0.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install QDev.CSharp.Pagination.PaginatedList as a Cake Addin
#addin nuget:?package=QDev.CSharp.Pagination.PaginatedList&version=1.0.1

// Install QDev.CSharp.Pagination.PaginatedList as a Cake Tool
#tool nuget:?package=QDev.CSharp.Pagination.PaginatedList&version=1.0.1

Paginated List Library

This library provides functionality for implementing paginated lists.

Table Of Contents

Installation

Using the NuGet package manager console within Visual Studio run the following command:

Install-Package QDev.CSharp.Pagination.PaginatedList

Or using the .NET Core CLI from a terminal window:

dotnet add package QDev.CSharp.Pagination.PaginatedList

PaginatedList<T> Class

Represents a paginated list of items.

Properties

Property Description
PageIndex Gets the current index page.
TotalPages Gets the total number of pages.
TotalCount Gets the total number of items.
HasPreviousPage Gets a value indicating whether the paginated list has a previous page.
HasNextPage Gets a value indicating whether the paginated list has a next page.

Constructors

Constructor Description
PaginatedList(IEnumerable<T> items, int count, int pageIndex, int pageSize) Initializes a new instance of the PaginatedList<T> class.
Example
var items = GetList(); // this return a huge list of items of intergers
var paginatedList = new PaginatedList<int>(items, count, pageIndex, pageSize);

PaginatedListExtension Class

Static Methods

Method Description
Create(IQueryable<T> source, int pageIndex, int pageSize) Creates a new instance of the PaginatedList<T> class.
CreateAsync(IQueryable<T> source, int pageIndex, int pageSize, CancellationToken cancellationToken) Asynchronously creates a new instance of the PaginatedList<T> class.

Note: Replace T with the actual type of the items you want to paginate.

Example
var items = GetList(); // this return a huge list of items of intergers
var paginatedList = PaginatedList<int>.Create(source, pageIndex, pageSize);
var paginatedListAsync = await PaginatedList<int>.CreateAsync(source, pageIndex, pageSize, cancellationToken);

How to use the PaginatedList<T> class

Here's an example of how to use the PaginatedList<T> class:

// Create a sample list of items
var items = new List<int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

// Set the pagination parameters
int pageIndex = 1;
int pageSize = 3;

// Create a paginated list
var paginatedList = PaginatedList<int>.Create(items.AsQueryable(), pageIndex, pageSize);

// Access the paginated list properties
Console.WriteLine($"Page {paginatedList.PageIndex} of {paginatedList.TotalPages}");
Console.WriteLine($"Total Items: {paginatedList.TotalCount}");

// Iterate through the paginated list
foreach (var item in paginatedList)
{
    Console.WriteLine(item);
}

// Check if the paginated list has a previous or next page
if (paginatedList.HasPreviousPage)
{
    Console.WriteLine("Has Previous Page");
}

if (paginatedList.HasNextPage)
{
    Console.WriteLine("Has Next Page");
}
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net7.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 238 10/30/2023
1.0.0 97 10/22/2023

fix documentation