コード例 #1
0
 /// <inheritdoc/>
 protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior)
 {
     return(ExecuteWithRetry(
                () =>
     {
         FixupParameters();
         InnerConnection.EnsureIsOpen();
         return InnerCommand.ExecuteReader(behavior);
     }));
 }
コード例 #2
0
 /// <inheritdoc/>
 public override object ExecuteScalar()
 {
     return(ExecuteWithRetry(
                () =>
     {
         FixupParameters();
         InnerConnection.EnsureIsOpen();
         return InnerCommand.ExecuteScalar();
     }));
 }
コード例 #3
0
 /// <inheritdoc/>
 public override int ExecuteNonQuery()
 {
     return(ExecuteWithRetry(
                () =>
     {
         FixupParameters();
         InnerConnection.EnsureIsOpen();
         return InnerCommand.ExecuteNonQuery();
     }));
 }
コード例 #4
0
        /// <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);
                });
            }));
        }