Method ExecuteScalarAsync
- Namespace
- Open.Database.Extensions
- Assembly
- Open.Database.Extensions.Core.dll
ExecuteScalarAsync<T>(BoundCall<ScalarKind<T>>, CancellationToken)
Runs the query and returns the first column of the first row, converted
as Map<T>() converts a column.
public static ValueTask<T> ExecuteScalarAsync<T>(this BoundCall<ScalarKind<T>> call, CancellationToken cancellationToken = default)
Parameters
callBoundCall<ScalarKind<T>>The bound call.
cancellationTokenCancellationTokenThe token that governs the call.
Returns
- ValueTask<T>
A task that represents the asynchronous operation; its result is the value.
Type Parameters
TThe type of the value.
Remarks
A NULL is null for a T that is
nullable or a reference type, and so is no row.
Exceptions
- ValueMappingException
There was no row or the value is NULL and
Tis a non-nullable value type (ask for the nullable type and use??for a default), the value does not convert toT, or it is out of its range (the conversion's own error is the inner exception).- InvalidOperationException
callis a default value, which is bound to nothing.- OperationCanceledException
cancellationTokenis canceled.