Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TransactionScope"/> class.
        /// </summary>
        public TransactionScope(
            TransactionMode mode         = TransactionMode.New,
            IsolationLevel isolation     = IsolationLevel.Unspecified,
            OnDispose ondispose          = OnDispose.Commit,
            ISessionScope parent         = null,
            ISessionFactoryHolder holder = null,
            IThreadScopeInfo scopeinfo   = null
            )
            : base(FlushAction.Config, isolation, ondispose, parent, holder, scopeinfo)
        {
            this.mode = mode;

            parentTransactionScope = ParentScope as TransactionScope;

            if (mode == TransactionMode.New)
            {
                if (parentTransactionScope != null)
                {
                    parentTransactionScope = null;
                    ParentScope            = null;
                }
                else
                {
                    parentTransactionScope = null;
                }
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DifferentDatabaseScope"/> class.
        /// </summary>
        public DifferentDatabaseScope(
            IDbConnection connection,
            FlushAction flushAction = FlushAction.Auto,
            ISessionScope parent = null,
            ISessionFactoryHolder holder = null,
            IThreadScopeInfo scopeinfo = null
            )
            : base(flushAction, parent: parent, holder: holder, scopeinfo: scopeinfo)
        {
            if (connection == null) throw new ArgumentNullException("connection");

            _connection = connection;
        }
        public void GoodErrorMessageIfTryingToUseScopeWithoutInitializingFramework()
        {
            //Need to do this because other tests may have already initialized the framework.
            IThreadScopeInfo scope = ThreadScopeAccessor.Instance.ScopeInfo;

            ThreadScopeAccessor.Instance.ScopeInfo = null;
            try
            {
                new SessionScope();
            }
            finally
            {
                ThreadScopeAccessor.Instance.ScopeInfo = scope;
            }
        }
Example #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DifferentDatabaseScope"/> class.
        /// </summary>
        public DifferentDatabaseScope(
            IDbConnection connection,
            FlushAction flushAction      = FlushAction.Auto,
            ISessionScope parent         = null,
            ISessionFactoryHolder holder = null,
            IThreadScopeInfo scopeinfo   = null
            )
            : base(flushAction, parent: parent, holder: holder, scopeinfo: scopeinfo)
        {
            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }

            _connection = connection;
        }
Example #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TransactionScope"/> class.
        /// </summary>
        public TransactionScope(
            TransactionMode mode = TransactionMode.New,
            IsolationLevel isolation = IsolationLevel.Unspecified,
            OnDispose ondispose = OnDispose.Commit,
            ISessionScope parent = null,
            ISessionFactoryHolder holder = null,
            IThreadScopeInfo scopeinfo = null
            )
            : base(FlushAction.Config, isolation, ondispose, parent, holder, scopeinfo)
        {
            this.mode = mode;

            parentTransactionScope = ParentScope as TransactionScope;

            if (mode == TransactionMode.New) {
                if (parentTransactionScope != null) {
                    parentTransactionScope = null;
                    ParentScope = null;
                } else {
                    parentTransactionScope = null;
                }
            }
        }