IRunicRowSource<TRow, TKey> interface

Namespace Runic.Application.Views in Runic.Application.Views 0.23.0

public interface IRunicRowSource<TRow, in TKey> where TKey : notnull

The rows of a RunicQueryCollection: an application's database table, HTTP API or in-memory list, read one range at a time.

Type parameters

TRow

The row type, a Bridge DTO.

TKey

The row key: a String, Guid or Int32.

Remarks

A source orders rows by the query's sort keys and then by key, so that a range is stable. The collection calls it from any thread, possibly concurrently, and cancels a call whose result nobody needs any more. It never calls it in a model turn. RunicQueryableRowSource implements it over an IQueryable with RunicQueryFields.

Methods

CountAsync

ValueTask<int> CountAsync(RunicQuery query, CancellationToken cancellationToken)

Counts the rows that match query's filters.

Parameters

query

The query.

cancellationToken

Cancels the count.

IndexOfAsync

ValueTask<int> IndexOfAsync(RunicQuery query, TKey key, CancellationToken cancellationToken)

Returns the position of the row with key in query's order, or -1.

Parameters

query

The query.

key

The row's key.

cancellationToken

Cancels the search.

LoadAsync

ValueTask<RunicRowPage<TRow>> LoadAsync(RunicQuery query, RunicRowRange range, CancellationToken cancellationToken)

Loads the rows of range in query's order.

Parameters

query

The query.

range

The rows to load. Fewer rows come back at the end of the list.

cancellationToken

Cancels the load.

Returns

The rows, and optionally the number of rows that match the query, such as from COUNT(*) OVER ().

Validate

void Validate(RunicQuery query)

Checks that the source can run query before the collection takes it.

Parameters

query

The query.

Exceptions

ArgumentException

The query names a field or filter the source does not have, or a value it cannot use. The page receives invalid-input, and the collection keeps its query.

Remarks

The query comes from a page and is untrusted: its field names, custom filter names and values are whatever the page sent. Reject every field, operator and value the source does not support by name, rather than passing them to a database. RunicQueryFields.Validate does so for registered fields.