Verständnis TransactionScopeOptions: RequiresNew = Suppress + Erforderlich?

Ich glaube, ich verstehe TransactionScopeOption.Suppress und TransactionScopeOption.Required aber ich habe Schwierigkeiten zu verstehen, was TransactionScopeOption.RequiresNew tut. Auf der Grundlage der letzten Erklärung, die ich gelesen habe, würden die folgenden beiden code-Blöcke funktional identisch sein? Dies ist eine genaue Darstellung dessen, was RequiresNew bedeutet?

using (var ts1 = new TransactionScope(TransactionScopeOption.RequiresNew))
{
  DoStuff();
  ts1.Complete();
}

und

using (var ts2 = new TransactionScope(TransactionScopeOptions.Suppress))
{
  using (var ts3 = new TransactionScope())
  {
    DoStuff();
    ts3.Complete();
  }

  ts2.Complete(); //not required but recommended for consistency's sake
}

InformationsquelleAutor Jaxidian | 2011-08-08

Schreibe einen Kommentar