Table of Contents

Method FirstOrDefaultAsync

Namespace
Open.Database.Extensions
Assembly
Open.Database.Extensions.Core.dll

FirstOrDefaultAsync(CancellationToken)

Asynchronously reads the first mapped row.

public ValueTask<T?> FirstOrDefaultAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Cancels the call, together with the cancellation token set on the underlying command: either one cancels it, whether it is opening the connection, looking up stored-procedure parameter names, executing or reading.

Returns

ValueTask<T>

A task that produces the first row, or default if the query returns no rows.

Remarks

Rows after the first are not mapped. Add an ORDER BY to the SQL when "first" must be deterministic.

Exceptions

OperationCanceledException

The operation was canceled.

See Also