Data Sorting & Pagination Models and Operations

H.Necessaire offers data pagination models and operations.

Data Sorting & Pagination Models and Operations
Photo by Olga Tutunaru / Unsplash
dotnet add package H.Necessaire

H.Necessaire

Presenting data in a paginated manner comes into play extremely often in any project. Therefore H.Necessaire comes with data models and operations for such scenarios so that it's uniform across modules and projects.

Page Model

class Page<T>
{
  T[] Content
  int PageIndex
  int PageSize
  int? TotalNumberOfPages
}

H.Necessaire's Page data model

Sort Filter Model

class SortFilter
{
  string By
  SortDirection Direction

  enum SortDirection
  {
    Ascending = 0
    Descending = 1
  }
}

interface ISortFilter
{
  SortFilter[] SortFilters
}

abstract class SortFilterBase : ISortFilter
{
  abstract string[] ValidSortNames
}

Page Filter Model

This model is to be used and interpreted by data providers

class PageFilter
{
  int PageIndex
  int PageSize
}

interface IPageFilter
{
  PageFilter PageFilter
}

Page Model Construction help static methods

Page<T>.For(IPageFilter pagefilter, long allCount, params T[] content)
Page<T>.Single(params T[] content)
Page<T>.Empty(int pageIndex = 0, int pageSize = 0, int totalNumberOfPages = 1)

Limited Enumerable model

The limited data stream model can be implemented and used by various data providers to be able to construct a page of data

interface ILimitedEnumerable<T> : IEnumerable<T>
{
  int Offset
  int Length
  long TotalNumberOfItems
}

View full models on GitHub:

H.Necessaire/Src/H.Necessaire/H.Necessaire/Models/Collections at master · hinteadan/H.Necessaire
A collection of useful data and execution extensions for .NET - hinteadan/H.Necessaire

Sample on GitHub Samples Repo

H.Necessaire.Usage.Samples/Src/H.Necessaire.Samples/H.Necessaire.Samples.SortingAndPagination/SampleDataProvider.cs at master · hinteadan/H.Necessaire.Usage.Samples
Usage Samples for H.Necessaire Docs WebSite. Contribute to hinteadan/H.Necessaire.Usage.Samples development by creating an account on GitHub.