Interface IContinuousQuerySource<T>
Represents an object which can be queried continuously.
public interface IContinuousQuerySource<T>
Type Parameters
TData type.
Methods
QueryContinuouslyAsync(ContinuousQueryOptions?, CancellationToken)
Starts a continuous query which listens to data events within the underlying table and returns an infinite IAsyncEnumerable<T> of batched events.
The query will be stopped when the IAsyncEnumerator<T> returned from
GetAsyncEnumerator(CancellationToken) call is disposed.
This happens automatically when you break out of the await foreach loop or use System.Linq.Async methods.
IAsyncEnumerable<ITableRowEventBatch<T>> QueryContinuouslyAsync(ContinuousQueryOptions? options = null, CancellationToken cancellationToken = default)
Parameters
optionsContinuousQueryOptionsOptions.
cancellationTokenCancellationTokenCancellation token.
Returns
- IAsyncEnumerable<ITableRowEventBatch<T>>
Infinite IAsyncEnumerable<T> representing an asynchronous stream of batched table events.
QueryContinuouslyAsync(Expression<Func<ITableRowEvent<T>, bool>>, ContinuousQueryOptions?, CancellationToken)
Starts a continuous query with a server-side filter expressed as a LINQ expression tree and returns an infinite IAsyncEnumerable<T> of batched events.
The expression is translated into a SQL predicate and evaluated on the server, so only matching events are sent to the client. This is a strongly-typed alternative to the SQL-string overload.
Member mapping. The following members of ITableRowEvent<T> are recognized inside the expression:- Entry
.<column>— current value (translates toCUR.<column>). For key-value views useEntry.Key.<column>orEntry.Value.<column>. - OldEntry
.<column>— old value (translates toOLD.<column>). - Type — event type (translates to
EVENT.TYPE_ID).
- Created: OldEntry columns are null; Entry contains the inserted row.
- Updated: both Entry and OldEntry are available.
- Removed: OldEntry contains the deleted row; Entry is null.
view.QueryContinuouslyAsync(e =>
e.Entry!.Price > 300 && e.Type == TableRowEventType.Updated);
The query is stopped when the IAsyncEnumerator<T> returned from
GetAsyncEnumerator(CancellationToken) is disposed. This happens automatically when you break out of
the await foreach loop or use System.Linq.Async methods.
[RequiresUnreferencedCode("LINQ provider does not support trimming and AOT scenarios. Use SQL queries instead.")]
IAsyncEnumerable<ITableRowEventBatch<T>> QueryContinuouslyAsync(Expression<Func<ITableRowEvent<T>, bool>> remoteFilter, ContinuousQueryOptions? options = null, CancellationToken cancellationToken = default)
Parameters
remoteFilterExpression<Func<ITableRowEvent<T>, bool>>Server-side filter as a LINQ expression over ITableRowEvent<T>.
optionsContinuousQueryOptionsContinuous query options, or null for defaults.
cancellationTokenCancellationTokenCancellation token.
Returns
- IAsyncEnumerable<ITableRowEventBatch<T>>
Infinite IAsyncEnumerable<T> representing an asynchronous stream of batched table events.
QueryContinuouslyAsync(string, ICollection<object?>?, ContinuousQueryOptions?, CancellationToken)
Starts a continuous query with a server-side SQL filter and returns an infinite IAsyncEnumerable<T> of batched events.
Only events matching remoteFilterSql are sent to the client. This reduces network traffic
by filtering events at the source before transmission.
CUR, OLD, and EVENT virtual table names to reference values:
CUR.<column>— current value of a column (after the operation).OLD.<column>— old value of a column (before the operation).EVENT.PARTITION_ID— partition ID (BIGINT).EVENT.TYPE_ID— event type ID (INT): 0=CREATED, 1=UPDATED, 2=REMOVED, 3=ARCHIVED (see TableRowEventType).EVENT.COMMIT_TIMESTAMP— physical commit timestamp, Unix time, in milliseconds (BIGINT).
Use ? for positional parameters supplied via remoteFilterArgs. Quote column names containing
spaces or reserved words with double quotes (e.g. CUR."column with spaces").
- Created:
OLDcolumns are null;CURcolumns contain the inserted row. - Updated: both
OLDandCURcolumns are available. - Removed:
OLDcolumns contain the deleted row;CURcolumns are null.
view.QueryContinuouslyAsync(
"CUR.PRICE > ? AND EVENT.TYPE_ID = ? AND EVENT.COMMIT_TIMESTAMP > ?",
[300, (int)TableRowEventType.Updated, DateTimeOffset.UtcNow.AddHours(-1).ToUnixTimeMilliseconds()]);
The query is stopped when the IAsyncEnumerator<T> returned from
GetAsyncEnumerator(CancellationToken) is disposed. This happens automatically when you break out of
the await foreach loop or use System.Linq.Async methods.
IAsyncEnumerable<ITableRowEventBatch<T>> QueryContinuouslyAsync(string remoteFilterSql, ICollection<object?>? remoteFilterArgs = null, ContinuousQueryOptions? options = null, CancellationToken cancellationToken = default)
Parameters
remoteFilterSqlstringServer-side SQL predicate; see remarks for the supported column-reference syntax.
remoteFilterArgsICollection<object>Positional arguments for
?placeholders inremoteFilterSql, or null.optionsContinuousQueryOptionsContinuous query options, or null for defaults.
cancellationTokenCancellationTokenCancellation token.
Returns
- IAsyncEnumerable<ITableRowEventBatch<T>>
Infinite IAsyncEnumerable<T> representing an asynchronous stream of batched table events.