Method FirstOrDefaultAsync
- Namespace
- Open.Database.Extensions
- Assembly
- Open.Database.Extensions.Core.dll
FirstOrDefaultAsync<T>(IMappedQuery<T>, CancellationToken)
Asynchronously reads the first mapped row.
public static ValueTask<T?> FirstOrDefaultAsync<T>(this IMappedQuery<T> query, CancellationToken cancellationToken = default)
Parameters
queryIMappedQuery<T>The query to execute.
cancellationTokenCancellationTokenCancels the operation. When it cannot be canceled, the cancellation token set on the underlying command applies.
Returns
Type Parameters
TThe type each row is mapped to.
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
-
SingleOrDefault<T>(IMappedQuery<T>)