Table of Contents

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

call BoundCall<ScalarKind<T>>

The bound call.

cancellationToken CancellationToken

The token that governs the call.

Returns

ValueTask<T>

A task that represents the asynchronous operation; its result is the value.

Type Parameters

T

The 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 T is a non-nullable value type (ask for the nullable type and use ?? for a default), the value does not convert to T, or it is out of its range (the conversion's own error is the inner exception).

InvalidOperationException

call is a default value, which is bound to nothing.

OperationCanceledException

cancellationToken is canceled.