SubSonic2.2 SharedDbConnectionScope and TransactionScope Transaction Confusion

ARGH !!!

There seems to be a bit of confusion around the SharedDbConnectionScope and TransactionScope objects, allowing you to wrap your SubSonic requests in a transaction.

The docs suggest specifying the use of SharedDbConnectionScope wrapped around using TransactionScope ...

using(SharedDbConnectionScope scope = new SharedDbConnectionScope())
{
  using(TransactionScope ts = new TransactionScope())
  {
    // do something
    ts.Complete();
  }
}

Then another question, for example, Subsonic: using SharedDbConnectionScope together with TransactionScope seems to be broken , suppose the documents are wrong, and two objects should be the other way around ...

using(TransactionScope ts = new TransactionScope())
{
  using(SharedDbConnectionScope scope = new SharedDbConnectionScope())
  {
    // do something
    ts.Complete();
  }
}

But looking into the source code, I am even more confused.

In the SqlQuery.cs code file, it has several ExecuteTransaction overloads. For example...

public static void ExecuteTransaction(List<SqlQuery> queries)
{
  using(SharedDbConnectionScope scope = new SharedDbConnectionScope())
  {
    using(TransactionScope ts = new TransactionScope())
    {
      foreach(SqlQuery q in queries)
        q.Execute();
    }
  }
}

... ... , ... ts.Complete()?

? , . ExecuteTransaction!

...

TransactionWithDtcOffTests.cs , , SharedDbConnectionScope TransactionScope -!

using(TransactionScope ts = new TransactionScope())
{
  using(SharedDbConnectionScope connScope = new SharedDbConnectionScope())
  {
    // <snip />
  }
}

SubSonic 2.2, , - .

-...

- , SubSonic2.2? ? ExecuteTransaction , ?

+3
2

SharedConnectionScope (SCS) TransactionScope (TS). SCS , MSDTC, TS, SCS, . TS Complete() .

+4

, SQL 2005 SCS TS SQL 2000 ( MSDTC) SCS TS. , ...

0

Source: https://habr.com/ru/post/1715987/


All Articles