Skip to content

IPage<T>

Namespace: SlottyMedia.Database.Pagination

This class represents a paginated list.

public interface IPage<T> : , System.Collections.IEnumerable

Type Parameters

T
The type of the page's elements

Implements IEnumerable<T>, IEnumerable

Properties

PageNumber

The number of this page. This number is always between 0 (inclusive) and IPage<T>.TotalPages (exclusive). This number is always 0 when no pages are available.

public abstract int PageNumber { get; }

Property Value

Int32

PageSize

The size of each page.

public abstract int PageSize { get; }

Property Value

Int32

TotalPages

The total number of pages. This number is at least 0.

public abstract int TotalPages { get; }

Property Value

Int32

HasNext

Whether there is a page that comes after this page.

public bool HasNext { get; }

Property Value

Boolean

HasPrevious

Whether there is a page that comes before this page.

public bool HasPrevious { get; }

Property Value

Boolean

Content

This page's elements as a list.

public abstract List<T> Content { get; }

Property Value

List<T>

Methods

Map<TMapped>(Func<T, TMapped>)

Maps the content of this page using the supplied function.

IPage<TMapped> Map<TMapped>(Func<T, TMapped> function)

Type Parameters

TMapped
The type of the resulting page's contents

Parameters

function Func<T, TMapped>
The function that maps all contents of this page

Returns

IPage<TMapped>
The mapped page

Fetch(Int32)

Fetches a matching page with the specified page number.

Task<IPage<T>> Fetch(int pageNumber)

Parameters

pageNumber Int32
The number of the page to fetch

Returns

Task<IPage<T>>
The requested page

FetchNext()

Fetches the next page. Returns this page instead if no such page exists. Consider checking IPage<T>.HasNext before invoking this method.

Task<IPage<T>> FetchNext()

Returns

Task<IPage<T>>
The next page

FetchPrevious()

Fetches the previous page. Returns this page instead if no such page exists. Consider checking IPage<T>.HasPrevious before invoking this method.

Task<IPage<T>> FetchPrevious()

Returns

Task<IPage<T>>
The previous page