Table of Contents

Class InfiniteQueryState<TData, TPageParam>

Namespace
DotNetQuery.Core
Assembly
DotNetQuery.Core.dll

An immutable snapshot of an infinite query's current state. Use the static factory methods to create instances.

public sealed record InfiniteQueryState<TData, TPageParam> : IEquatable<InfiniteQueryState<TData, TPageParam>>

Type Parameters

TData

The type of a single page of data.

TPageParam

The type of the page parameter (cursor/offset).

Inheritance
InfiniteQueryState<TData, TPageParam>
Implements
IEquatable<InfiniteQueryState<TData, TPageParam>>
Inherited Members

Properties

Error

The exception from the most recent failed fetch. null when not in a failure state.

public Exception? Error { get; }

Property Value

Exception

HasData

true when at least one page has been successfully loaded.

public bool HasData { get; }

Property Value

bool

HasError

true when Error is not null.

public bool HasError { get; }

Property Value

bool

HasNextPage

true when a next page is available to fetch.

public bool HasNextPage { get; }

Property Value

bool

HasPreviousPage

true when a previous page is available to fetch.

public bool HasPreviousPage { get; }

Property Value

bool

IsFailure

true when Status is Failure.

public bool IsFailure { get; }

Property Value

bool

IsFetching

true when Status is Fetching.

public bool IsFetching { get; }

Property Value

bool

IsFetchingNextPage

true while a FetchNextPage() is in progress. Existing pages remain visible during this state.

public bool IsFetchingNextPage { get; }

Property Value

bool

IsFetchingPreviousPage

true while a FetchPreviousPage() is in progress. Existing pages remain visible during this state.

public bool IsFetchingPreviousPage { get; }

Property Value

bool

IsIdle

true when Status is Idle.

public bool IsIdle { get; }

Property Value

bool

IsSuccess

true when Status is Success.

public bool IsSuccess { get; }

Property Value

bool

PageParams

The page parameters used to fetch each page in Pages. PageParams[i] was the parameter used to fetch Pages[i].

public IReadOnlyList<TPageParam> PageParams { get; }

Property Value

IReadOnlyList<TPageParam>

Pages

All currently loaded pages, ordered from oldest to newest.

public IReadOnlyList<TData> Pages { get; }

Property Value

IReadOnlyList<TData>

Status

The current lifecycle status of the query.

public QueryStatus Status { get; }

Property Value

QueryStatus

Methods

CreateFailure(Exception, IReadOnlyList<TData>, IReadOnlyList<TPageParam>, bool, bool)

Creates a Failure state, preserving pages from the last successful fetch.

public static InfiniteQueryState<TData, TPageParam> CreateFailure(Exception error, IReadOnlyList<TData> pages, IReadOnlyList<TPageParam> pageParams, bool hasNextPage, bool hasPreviousPage)

Parameters

error Exception
pages IReadOnlyList<TData>
pageParams IReadOnlyList<TPageParam>
hasNextPage bool
hasPreviousPage bool

Returns

InfiniteQueryState<TData, TPageParam>

CreateFetching(IReadOnlyList<TData>, IReadOnlyList<TPageParam>, bool, bool)

Creates a Fetching state that carries existing pages for stale-while-revalidate display during a full refetch.

public static InfiniteQueryState<TData, TPageParam> CreateFetching(IReadOnlyList<TData> pages, IReadOnlyList<TPageParam> pageParams, bool hasNextPage, bool hasPreviousPage)

Parameters

pages IReadOnlyList<TData>
pageParams IReadOnlyList<TPageParam>
hasNextPage bool
hasPreviousPage bool

Returns

InfiniteQueryState<TData, TPageParam>

CreateFetchingNext(IReadOnlyList<TData>, IReadOnlyList<TPageParam>, bool, bool)

Creates a success state with IsFetchingNextPage set. Existing pages remain visible while the next page loads.

public static InfiniteQueryState<TData, TPageParam> CreateFetchingNext(IReadOnlyList<TData> pages, IReadOnlyList<TPageParam> pageParams, bool hasNextPage, bool hasPreviousPage)

Parameters

pages IReadOnlyList<TData>
pageParams IReadOnlyList<TPageParam>
hasNextPage bool
hasPreviousPage bool

Returns

InfiniteQueryState<TData, TPageParam>

CreateFetchingPrevious(IReadOnlyList<TData>, IReadOnlyList<TPageParam>, bool, bool)

Creates a success state with IsFetchingPreviousPage set. Existing pages remain visible while the previous page loads.

public static InfiniteQueryState<TData, TPageParam> CreateFetchingPrevious(IReadOnlyList<TData> pages, IReadOnlyList<TPageParam> pageParams, bool hasNextPage, bool hasPreviousPage)

Parameters

pages IReadOnlyList<TData>
pageParams IReadOnlyList<TPageParam>
hasNextPage bool
hasPreviousPage bool

Returns

InfiniteQueryState<TData, TPageParam>

CreateIdle()

Creates an Idle state with no pages.

public static InfiniteQueryState<TData, TPageParam> CreateIdle()

Returns

InfiniteQueryState<TData, TPageParam>

CreateSuccess(IReadOnlyList<TData>, IReadOnlyList<TPageParam>, bool, bool)

Creates a settled Success state with the given pages.

public static InfiniteQueryState<TData, TPageParam> CreateSuccess(IReadOnlyList<TData> pages, IReadOnlyList<TPageParam> pageParams, bool hasNextPage, bool hasPreviousPage)

Parameters

pages IReadOnlyList<TData>
pageParams IReadOnlyList<TPageParam>
hasNextPage bool
hasPreviousPage bool

Returns

InfiniteQueryState<TData, TPageParam>