The TransactionManager.BeginTransaction method is used to begin a new transaction in a database. This method takes a transaction isolation level as a parameter and returns a new instance of the Transaction class, which represents the started transaction.
Example 1:
using System.Transactions;
using System.Data.SqlClient;
...
// Create a connection to the database
SqlConnection connection = new SqlConnection("connection string");
connection.Open();
// Begin a new transaction with ReadCommitted isolation level
var transaction = TransactionManager.BeginTransaction(IsolationLevel.ReadCommitted);
// Execute some SQL commands within the transaction
SqlCommand command1 = new SqlCommand("INSERT INTO Table1 VALUES (1, 'Value1')", connection, transaction);
SqlCommand command2 = new SqlCommand("INSERT INTO Table2 VALUES (2, 'Value2')", connection, transaction);
// Determine Package Library: System.Transactions namespace in the .NET Framework Class Library.
C# (CSharp) TransactionManager.BeginTransaction - 42 examples found. These are the top rated real world C# (CSharp) examples of TransactionManager.BeginTransaction extracted from open source projects. You can rate examples to help us improve the quality of examples.