the most effective should use BeginTransaction, etc. on yours DbConnection, but that isnβt since you have to use the same connection and everyone DbCommandneeds to configure transaction , etc.
TransactionScope, and if you are on SQL Server 2005 or higher, you rarely notice a significant performance difference between this and BeginTransaction:
using(var tran = new TransactionScope()) {
SaveA();
SaveB();
SaveC();
SaveD();
tran.Complete();
}
It doesnβt matter if it uses SaveAetc. one connection since it SqlConnectionwill automatically close at TransactionScope.
Alternatively, let ORM handle this for you; most of them will create transactions to save a group of changes.
, ; TransactionScope (DTC), ( WPF, ).