A .NET transaction is created by calling the BeginTransaction( ) method on the Connection object. All subsequent operations associated with the transaction, such as committing or aborting the transaction, are performed using the Transaction object.
Transactions should be used only when required. Using transactions imposes a performance penalty due to the system overhead in managing the transaction. Transactions can also block work of other users in the system, which causes performance problems. For that reason, if transactions are required, the isolation level of the transactions should be carefully considered .
Because the Transaction is a connected class, each .NET data provider implements its own Transaction class, with a similar interface and function as other Transaction classes but in its own unique namespace. The Transaction class namespaces for several ADO.NET data providers are listed in Table 31-1.
Table 31-1. Provider-specific transaction classes
The commonly used public properties of the Transaction class are listed in Table 31-2.
Table 31-2. Transaction properties
The commonly used public methods of the Transaction class are listed in Table 31-3.
Table 31-3. Transaction methods
The Transaction class inherits from MarshalByRefObject and implements the IDbTransaction and IDisposable interfaces. Public static members of this class are safe for multithreaded operations; instance members aren't guaranteed thread-safe.