Method SingleOrDefaultAsync
- Namespace
- Open.Database.Extensions
- Assembly
- Open.Database.Extensions.Core.dll
SingleOrDefaultAsync<T>(IMappedQuery<T>, CancellationToken)
Asynchronously reads the only mapped row.
public static ValueTask<T?> SingleOrDefaultAsync<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.
Exceptions
- OperationCanceledException
The operation was canceled.
- InvalidOperationException
The query returns more than one row.
- See Also
-
FirstOrDefault<T>(IMappedQuery<T>)