w0051977
w0051977

Reputation: 15817

TransactionScope v SQLTransaction

I have found the following quote: "It is recommended that you create implicit transactions using the TransactionScope class" on this website: http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx. Has TransacrtionScope replaced the SQLTransaction class? i.e. should all new applications/transaction functionality use the TransactionScope class? If this is the case then I assume that SQLTransaction is just there so that legacy apps don't need changing?

I have read many webpages suggesting that TransactionScope should be used if multiple connections are used, but should TransactionScope be used if you have a signle connection that performs multiple operations that should be treated as an atomic unit of work?

Upvotes: 4

Views: 3557

Answers (1)

SeanKuehnel
SeanKuehnel

Reputation: 41

I personally like transactionScope because your queries to your database don't require a parameter for the sqlTransaction (or connection) or other related code to maintain the transaction. This typically allows your service/business layer to manage the transaction entirely which to me just reads cleaner.

Upvotes: 1

Related Questions