C# Class Tiraggo.Interfaces.tgTransactionScope

This is the EntitySpaces ADO.NET connection based transaction class that mimics the System.Transactions.TransactionScope class.
EntitySpaces supports two transactions models, connection based via this class (tgTransactionScope) and the new System.Transactions.TransactionScope. Some databases such as Microsoft Access don't support the new System.Transactions.TransactionScope class. And still there are other cases where the System.Transactions.TransactionScope class cannot be used as is the case with a lot of hosting companies. Thus EntitySpaces provides a very nice ADO.NET connection based transaction handler. The Syntax should be as follows: using (tgTransactionScope scope = new tgTransactionScope()) { // Logic here ... scope.Complete(); // last line of using statement } Note that if an exception is thrown scope.Complete will not be called, and the transaction upon leaving the using statement will be rolled back. You indicate whether you want the provider to use the tgTransactionScope or the System.Transactions.TransactionScope class in your .config file. Notice in the config file setting below that providerClass="DataProvider". This indicates that you want to use the tgTransactionScope class, use providerClass="DataProviderEnterprise" to use System.Transactions.TransactionScope. <add name="SQL" providerMetadataKey="esDefault" sqlAccessType="DynamicSQL" provider="Tiraggo.SqlClientProvider" providerClass="DataProvider" connectionString="User ID=sa;Password=griffinski;Initial Catalog=Northwind;Data Source=localhost" databaseVersion="2005"/>
Inheritance: IDisposable
Afficher le fichier Open project: BrewDawg/Tiraggo Class Usage Examples

Méthodes publiques

Méthode Description
AddForCommit ( ICommittable commit ) : bool

You should never call this directly, EntitySpaces calls this internally.

Complete ( ) : void

You must call Complete to commit the transaction. Calls and transactions can be nested, only the final outer call to Complete will commit the transaction.

DeEnlist ( IDbCommand cmd ) : void

You should never call this directly, the providers call this method.

Enlist ( IDbCommand cmd, string connectionString, CreateIDbConnectionDelegate creator ) : void

You should never call this directly, the providers call this method.

GetCurrentTransactionScopeOption ( ) : tgTransactionScopeOption

This can be used to get the tgTransactionScopeOption from the current tgTransactionScope (remember transactions can be nested). If there is no on-going transaction then tgTransactionScopeOption.None is returned.

tgTransactionScope ( ) : System

The default constructor, this transactions tgTransactionScopeOption will be set to Required. The IsolationLevel is set to Unspecified. using (tgTransactionScope scope = new tgTransactionScope()) { // Do your work here scope.Complete(); }

tgTransactionScope ( tgTransactionScopeOption option ) : System

Use this constructor to control the tgTransactionScopeOption as it applies to this transaction. using (tgTransactionScope scope = new tgTransactionScope(tgTransactionScopeOption.RequiresNew)) { // Do your work here scope.Complete(); }

tgTransactionScope ( tgTransactionScopeOption option, IsolationLevel level ) : System

Use this constructor to control the tgTransactionScopeOption as it applies to this transaction. using (tgTransactionScope scope = new tgTransactionScope(tgTransactionScopeOption.RequiresNew, IsolationLevel.ReadCommitted)) { // Do your work here scope.Complete(); }

Méthodes protégées

Méthode Description
CommonInit ( tgTransactionScope tx ) : void

This is the common constructor logic, tx is "this" from the constructor

Private Methods

Méthode Description
GetCurrentTx ( ) : tgTransactionScope

Internal method.

IDisposable ( ) : void

Internal. Called when the "using" statement is exited.

Rollback ( ) : void

Internal method, called if the "using" statement is left without calling scope.Complete()

Method Details

AddForCommit() public static méthode

You should never call this directly, EntitySpaces calls this internally.
public static AddForCommit ( ICommittable commit ) : bool
commit ICommittable Any class that implements ICommittable
Résultat bool

CommonInit() protected static méthode

This is the common constructor logic, tx is "this" from the constructor
protected static CommonInit ( tgTransactionScope tx ) : void
tx tgTransactionScope
Résultat void

Complete() public méthode

You must call Complete to commit the transaction. Calls and transactions can be nested, only the final outer call to Complete will commit the transaction.
public Complete ( ) : void
Résultat void

DeEnlist() public static méthode

You should never call this directly, the providers call this method.
public static DeEnlist ( IDbCommand cmd ) : void
cmd IDbCommand The command to enlist into a transaction
Résultat void

Enlist() public static méthode

You should never call this directly, the providers call this method.
public static Enlist ( IDbCommand cmd, string connectionString, CreateIDbConnectionDelegate creator ) : void
cmd IDbCommand The command to enlist into a transaction
connectionString string The connection string passed to the CreateIDbConnectionDelegate delegate
creator CreateIDbConnectionDelegate The delegate previously registered by the provider
Résultat void

GetCurrentTransactionScopeOption() public static méthode

This can be used to get the tgTransactionScopeOption from the current tgTransactionScope (remember transactions can be nested). If there is no on-going transaction then tgTransactionScopeOption.None is returned.
public static GetCurrentTransactionScopeOption ( ) : tgTransactionScopeOption
Résultat tgTransactionScopeOption

tgTransactionScope() public méthode

The default constructor, this transactions tgTransactionScopeOption will be set to Required. The IsolationLevel is set to Unspecified. using (tgTransactionScope scope = new tgTransactionScope()) { // Do your work here scope.Complete(); }
public tgTransactionScope ( ) : System
Résultat System

tgTransactionScope() public méthode

Use this constructor to control the tgTransactionScopeOption as it applies to this transaction. using (tgTransactionScope scope = new tgTransactionScope(tgTransactionScopeOption.RequiresNew)) { // Do your work here scope.Complete(); }
public tgTransactionScope ( tgTransactionScopeOption option ) : System
option tgTransactionScopeOption See
Résultat System

tgTransactionScope() public méthode

Use this constructor to control the tgTransactionScopeOption as it applies to this transaction. using (tgTransactionScope scope = new tgTransactionScope(tgTransactionScopeOption.RequiresNew, IsolationLevel.ReadCommitted)) { // Do your work here scope.Complete(); }
public tgTransactionScope ( tgTransactionScopeOption option, IsolationLevel level ) : System
option tgTransactionScopeOption See
level IsolationLevel See IsolationLevel in the System.Data namespace
Résultat System