DbCommand.ExecuteDbDataReaderAsync(CommandBehavior, CancellationToken) DbCommand.ExecuteDbDataReaderAsync(CommandBehavior, CancellationToken) DbCommand.ExecuteDbDataReaderAsync(CommandBehavior, CancellationToken) Method

定义

提供程序应执行该方法对 ExecuteReader 重载提供非默认的实现。Providers should implement this method to provide a non-default implementation for ExecuteReader overloads.

默认实现调用同步 ExecuteReader() 方法并返回已完成任务,以便阻止调用线程。The default implementation invokes the synchronous ExecuteReader() method and returns a completed task, blocking the calling thread. 如果传递到已取消的取消标记,则默认实现将返回已取消的任务。The default implementation will return a cancelled task if passed an already cancelled cancellation token. ExecuteReader 引发的异常将通过返回的任务异常属性传递。Exceptions thrown by ExecuteReader will be communicated via the returned Task Exception property.

该方法可用于请求操作之前接受取消标记。This method accepts a cancellation token that can be used to request the operation to be cancelled early. 实现可能会忽略该请求。Implementations may ignore this request.

protected:
 virtual System::Threading::Tasks::Task<System::Data::Common::DbDataReader ^> ^ ExecuteDbDataReaderAsync(System::Data::CommandBehavior behavior, System::Threading::CancellationToken cancellationToken);
protected virtual System.Threading.Tasks.Task<System.Data.Common.DbDataReader> ExecuteDbDataReaderAsync (System.Data.CommandBehavior behavior, System.Threading.CancellationToken cancellationToken);
abstract member ExecuteDbDataReaderAsync : System.Data.CommandBehavior * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Data.Common.DbDataReader>
override this.ExecuteDbDataReaderAsync : System.Data.CommandBehavior * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Data.Common.DbDataReader>

参数

behavior
CommandBehavior CommandBehavior CommandBehavior

语句执行和数据检索的选项。Options for statement execution and data retrieval.

cancellationToken
CancellationToken CancellationToken CancellationToken

要监视取消请求的标记。The token to monitor for cancellation requests.

返回

表示异步操作的任务。A task representing the asynchronous operation.

异常

执行命令文本时出现的一个错误。An error occurred while executing the command text.

注解

有关异步编程的详细信息,请参阅异步编程For more information about asynchronous programming, see Asynchronous Programming.

适用于

另请参阅