Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TransScope"/> class.
 /// </summary>
 /// <param name="connectionString">The connection string.</param>
 /// <param name="option">The option.</param>
 public TransScope(string connectionString, TransScopeOption option)
 {
     _connectionManager = ConnectionManager.GetManager(connectionString);
     if (!_connectionManager.IsExistDbTransaction() || option == TransScopeOption.RequiresNew)
     {
         _tran = _connectionManager.BeginTransaction();
         _beginTransactionIsInCurrentTransScope = true;
     }
     else
     {
         _tran = _connectionManager.Transaction;
     }
 }
Ejemplo n.º 2
0
        public static ConnectionManager GetManager(string connectionString)
        {
            ConnectionManager mgr = null;
            if (!ApplicationContext.LocalContext.Contains(connectionString))
                lock (_lock)
                {
                    if (!ApplicationContext.LocalContext.Contains(connectionString))
                    {
                        mgr = new ConnectionManager(connectionString);
                        ApplicationContext.LocalContext[connectionString] = mgr;
                    }
                }
            mgr = (ConnectionManager)(ApplicationContext.LocalContext[connectionString]);

            mgr.AddRef();
            return mgr;
        }