Pretty easy, don't you think so? TransactionScope will take care of all the transactional related stuff in the above code block. We need to commit the transaction by calling the ts.Complete() method. As the connection object itself is confined within the scope so it automatically participates in the transaction.(Kindly note as its a code snippet so everything is not defined here properly as its only part of the whole demo project)
Please explore more the transaction context with Transaction.Current. And last but not the least thing that this feature is not limited to SQL Server operations. You can use the same transaction for Oracle, SQL Server data-storages, MSMQ messaging and even bulk copying filesystem operations.
Please explore more the transaction context with Transaction.Current. And last but not the least thing that this feature is not limited to SQL Server operations. You can use the same transaction for Oracle, SQL Server data-storages, MSMQ messaging and even bulk copying filesystem operations.