Table of Contents

Interface ITableProvider

Namespace
Htmx.Components.Table
Assembly
Htmx.Components.dll

Provides functionality for fetching and processing table data with Entity Framework Core support.

public interface ITableProvider
Extension Methods

Remarks

The table provider handles pagination, filtering, sorting, and data retrieval for table models. It works specifically with Entity Framework Core queryables and provides async operations for optimal performance.

Methods

FetchPageAsync<T, TKey>(TableModel<T, TKey>, IQueryable<T>, TableState)

Uses the given columns and tableState to extend the given queryable for appropriate filtering and sorting, and then executes the query twice; once with .CountAsync() so that PageCount can be calculated, and once with pagination applied. Places the results in the given TableModel<T, TKey>. The queryable is expected to be an EF Core queryable.

Task FetchPageAsync<T, TKey>(TableModel<T, TKey> tableModel, IQueryable<T> query, TableState tableState) where T : class

Parameters

tableModel TableModel<T, TKey>

The table model to populate with data and metadata.

query IQueryable<T>

The Entity Framework Core queryable to execute.

tableState TableState

The current state of the table including filters, sorting, and pagination.

Returns

Task

A task that represents the asynchronous operation.

Type Parameters

T

The entity type being queried.

TKey

The key type for the entity.

Remarks

This method applies filtering, sorting, and pagination to the query in sequence, then executes both a count query and a data query to populate the table model with the appropriate page of data and total page count.

Exceptions

ArgumentNullException

Thrown when any parameter is null.

InvalidOperationException

Thrown when no sortable column is found for default sorting.