3

System.Data.SqlClient.SqlTransactionのDispose()メソッドを(逆コンパイラーを使用して)調べました。

 protected override void Dispose(bool disposing)
    {
      if (disposing)
      {
        SNIHandle target = (SNIHandle) null;
        RuntimeHelpers.PrepareConstrainedRegions();
        try
        {
          target = SqlInternalConnection.GetBestEffortCleanupTarget(this._connection);
          if (!this.IsZombied)
          {
            if (!this.IsYukonPartialZombie)
              this._internalTransaction.Dispose();
          }
        }
        catch (OutOfMemoryException ex)
        {
          this._connection.Abort((Exception) ex);
          throw;
        }
        catch (StackOverflowException ex)
        {
          this._connection.Abort((Exception) ex);
          throw;
        }
        catch (ThreadAbortException ex)
        {
          this._connection.Abort((Exception) ex);
          SqlInternalConnection.BestEffortCleanup(target);
          throw;
        }
      }
      base.Dispose(disposing);
    }

なぜ誰もがフォーラムでそれが処分でロールバックしていると言うのですか?どこでロールバックしますか?

4

1 に答える 1

4

@BlorgBeardは、「内部トランザクションはそれ自体のDispose、つまりthis._internalTransaction.Dispose();でロールバックすると思います」と言って正しいです。他の人への答えとしてそれを書く。(最後のステートメントを参照)

System.Data.SqlClient.SqlInternalTransaction.Dispose()のコード-最後の行を参照してください:

private void Dispose(bool disposing)
{
  Bid.PoolerTrace("<sc.SqlInteralTransaction.Dispose|RES|CPOOL> %d#, Disposing\n", this.ObjectID);
  if (!disposing || this._innerConnection == null)
    return;
  this._disposing = true;
  this.Rollback();
}
于 2012-06-25T22:10:15.853 に答える