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 operation. When it cannot be canceled, the cancellation token set on the underlying command applies.

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