/// <inheritdoc/> protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior) { return(ExecuteWithRetry( () => { FixupParameters(); InnerConnection.EnsureIsOpen(); return InnerCommand.ExecuteReader(behavior); })); }
/// <inheritdoc/> public override object ExecuteScalar() { return(ExecuteWithRetry( () => { FixupParameters(); InnerConnection.EnsureIsOpen(); return InnerCommand.ExecuteScalar(); })); }
/// <inheritdoc/> public override int ExecuteNonQuery() { return(ExecuteWithRetry( () => { FixupParameters(); InnerConnection.EnsureIsOpen(); return InnerCommand.ExecuteNonQuery(); })); }
/// <summary> /// Executes the command asynchronously with retry. /// </summary> /// <param name="commandBehavior">The commandBehavior to execute with.</param> /// <param name="cancellationToken">The cancellationToken to use for the operation.</param> /// <returns>A task that provides an IDataReader of the results when complete.</returns> internal Task <IDataReader> GetReaderAsync(CommandBehavior commandBehavior, CancellationToken cancellationToken) { // fallback to calling execute reader in a blocking task return(ExecuteWithRetryAsync(() => { FixupParameters(); InnerConnection.EnsureIsOpen(); // start the sql command executing var sqlCommand = InnerCommand as System.Data.SqlClient.SqlCommand; if (sqlCommand != null) { return Task <IDataReader> .Factory.FromAsync(sqlCommand.BeginExecuteReader(commandBehavior), ar => sqlCommand.EndExecuteReader(ar)); } return Task <IDataReader> .Factory.StartNew( () => { cancellationToken.ThrowIfCancellationRequested(); return InnerCommand.ExecuteReader(commandBehavior); }); })); }