.net - TransactionScope vs. IDbTransaction -


What are the advantages / disadvantages of using TransactionScope compared to IDbTransaction? I give some suggestions - please correct / complete the list

Profit from a transaction:

  1. Transaction skip supports distributed transactions - You can access many data sources or a lane - Use multiple connections for a data source within the bin.
  2. Transaction scope is more declarative: we can nest in the monitoring of transactions and it is more enjoyable to use the services layer (we do not have to handle IDBIcNation and IDB transaction ourselves) .
  3. I'm not sure about the third point, but here it is. IDbTransaction is specific to the connection - you have to keep the connection open throughout the transaction. I'm not sure the connection / connection should be opened during the entire transaction (please clarify it). If not, then the following workflow is possible: start transactions, open connections - queries - retrieve - close connections, perform resource-intensive calculations (closing connections), open connections - queries - retrieve - near Connection, ..., transactions, but I think it is impossible that the Transcendescope remains open to the connection until the commitment.

    Transaction loss:

    1. It is not that support isolation level during the transaction.

      feature very - especially when wrapping this code Which can be used for you can not control (since the code you typed will automatically be received by default). This means that you can keep pre-existing libraries using the server

      In the display minor is killed, but note that in many cases you can use the light transaction manager DTC will use - this means that you do not pay the full DTC costs.

      Another disadvantage is that nested transactions can not be brought back; any rollback immediately External transaction rolls back privately I like this approach; If things get sick - stop them from doing ASAP.

      Repeat your query in 3 points; You can choose / close the number of connections within the scope of the transaction, without affecting the behavior, except you can get (depends on the circumstances) that your transaction is DTC If you talk to many transaction-aware servers, it gives a lot of guarantee.

      Another difference: Different timeouts apply, especially if DTC is included that makes sense: A long-running distributed transaction is poison, and it is a cross-server deadlock Can indicate. Deadlocks are usually found on the single server, but it is impossible to automatically spot when delivered, therefore a difficult time is required.

Comments