Question

So because the OracleCommand class extends the DbCommand class it implements the Async versions of it's Execute methods. However, I cannot find any reference to that OracleCommand class supporting these methods from Oracle (I am using 11g): http://docs.oracle.com/html/E10927_01/OracleCommandClass.htm

Do anyone know what this is doing under the hood to support these methods? They appear to be non-blocking and support cancellation in usage (I expected a NotImplementedException to be honest), but this feels unsupported to me because of the documentation so I want to make sure that there aren't any gotchas.

Était-ce utile?

La solution

The Oracle client doesn't override the async versions of the methods. They use the default DbCommand implementnations which call the non-async versions of the methods.

For example, the implementation of ExecuteNonQueryAsync is:

// System.Data.Common.DbCommand
public virtual Task<int> ExecuteNonQueryAsync(CancellationToken cancellationToken)
{
    if (cancellationToken.IsCancellationRequested)
    {
        return ADP.CreatedTaskWithCancellation<int>();
    }
    CancellationTokenRegistration cancellationTokenRegistration = default(CancellationTokenRegistration);
    if (cancellationToken.CanBeCanceled)
    {
        cancellationTokenRegistration = cancellationToken.Register(new Action(this.CancelIgnoreFailure));
    }
    Task<int> result;
    try
    {
        result = Task.FromResult<int>(this.ExecuteNonQuery());
    }
    catch (Exception ex)
    {
        cancellationTokenRegistration.Dispose();
        result = ADP.CreatedTaskWithException<int>(ex);
    }
    return result;
}

As you can see, it simply calls ExecuteNonQuery under the hood (the no-parameter overload of ExecuteNonQueryAsync calls this version of the method).

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top