Skip to content

Add calculated 'HasMore' property to 'PaginatedResult' #1

@carusology

Description

@carusology

Background

When returning paginated results, one often wants to know "are there any more results after this page?" We do all the time in our closed source code. Consumers of the PaginatedResult<T> value object can use the Offset, Results.Count, and Total properties to deterministically calculate whether or not there are more results after the current page in the overall list of results. However, rather than require all consumers of this value object to implement this calculation themselves, let's provide it as a first class property.

Task

  • Enhance PaginatedResult<T> to throw exceptions on invalid input that prevent a deterministic calculation of HasMore (null result set, negative total, result set + offset > total, etc.)
  • Enhance PaginationResult<T> to include a HasMore property that is calculated like so:
hasMore = (page.Offset + page.Results.Count) < page.Total;

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions