Table of Contents

Class Slice<T>

Namespace
Olve.Utilities.Paginations
Assembly
Olve.Utilities.dll

A contiguous slice of items from a larger collection, addressed by offset and limit, with metadata describing position within that collection.

public sealed record Slice<T> : IEquatable<Slice<T>>

Type Parameters

T
Inheritance
Slice<T>
Implements
Inherited Members

Constructors

Slice(IReadOnlyList<T>, int, int, int)

A contiguous slice of items from a larger collection, addressed by offset and limit, with metadata describing position within that collection.

public Slice(IReadOnlyList<T> Items, int Offset, int Limit, int TotalCount)

Parameters

Items IReadOnlyList<T>

The items in this slice.

Offset int

Zero-based index of the first item of this slice within the collection.

Limit int

Maximum number of items per slice.

TotalCount int

Total number of items in the collection.

Properties

HasMore

Whether more items exist after this slice.

public bool HasMore { get; }

Property Value

bool

Items

The items in this slice.

public IReadOnlyList<T> Items { get; init; }

Property Value

IReadOnlyList<T>

Limit

Maximum number of items per slice.

public int Limit { get; init; }

Property Value

int

Next

The OffsetPagination that would fetch the next slice, or null when this is the last slice.

public OffsetPagination? Next { get; }

Property Value

OffsetPagination?

Offset

Zero-based index of the first item of this slice within the collection.

public int Offset { get; init; }

Property Value

int

TotalCount

Total number of items in the collection.

public int TotalCount { get; init; }

Property Value

int

Methods

TryToPage(out Page<T>?)

Converts this slice to the equivalent Page<T>. This is only possible when Offset is a multiple of Limit (see TryToPagination(out Pagination)).

public bool TryToPage(out Page<T>? page)

Parameters

page Page<T>

The equivalent page, or null when no equivalent exists.

Returns

bool

true if an equivalent page exists; otherwise false.