private bool _active;                // Is the transaction active?

        internal SqlDelegatedTransaction(SqlInternalConnection connection, Transaction tx)
        {
            Debug.Assert(null != connection, "null connection?");
            _connection        = connection;
            _atomicTransaction = tx;
            _active            = false;
            Transactions.IsolationLevel systxIsolationLevel = (Transactions.IsolationLevel)tx.IsolationLevel;

            // We need to map the System.Transactions IsolationLevel to the one
            // that System.Data uses and communicates to SqlServer.  We could
            // arguably do that in Initialize when the transaction is delegated,
            // however it is better to do this before we actually begin the process
            // of delegation, in case System.Transactions adds another isolation
            // level we don't know about -- we can throw the exception at a better
            // place.
            _isolationLevel = systxIsolationLevel switch
            {
                Transactions.IsolationLevel.ReadCommitted => IsolationLevel.ReadCommitted,
                Transactions.IsolationLevel.ReadUncommitted => IsolationLevel.ReadUncommitted,
                Transactions.IsolationLevel.RepeatableRead => IsolationLevel.RepeatableRead,
                Transactions.IsolationLevel.Serializable => IsolationLevel.Serializable,
                Transactions.IsolationLevel.Snapshot => IsolationLevel.Snapshot,
                _ => throw SQL.UnknownSysTxIsolationLevel(systxIsolationLevel),
            };
        }
Beispiel #2
0
 internal static Exception UnknownSysTxIsolationLevel(Transactions.IsolationLevel isolationLevel)
 {
     return(ADP.InvalidOperation(SR.GetString(SR.SQL_UnknownSysTxIsolationLevel, isolationLevel.ToString())));
 }