Επεξεργασία

Κοινή χρήση μέσω


DbBatch.ExecuteScalarAsync(CancellationToken) Method

Definition

An asynchronous version of ExecuteScalar(), which executes the batch and returns the first column of the first row in the first returned result set. All other columns, rows and result sets are ignored.

public abstract System.Threading.Tasks.Task<object?> ExecuteScalarAsync (System.Threading.CancellationToken cancellationToken = default);
abstract member ExecuteScalarAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task<obj>
Public MustOverride Function ExecuteScalarAsync (Optional cancellationToken As CancellationToken = Nothing) As Task(Of Object)

Parameters

cancellationToken
CancellationToken

A token to cancel the asynchronous operation.

Returns

The first column of the first row in the first result set.

Exceptions

An error occurred while executing the batch.

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by ExecuteScalar().

Applies to