Inheritance: IDisposable
Esempio n. 1
0
 internal DataAccessTransaction(DataAccessIsolationLevel isolationLevel, DataAccessScope scope, TimeSpan timeout)
 {
     this.timeout           = timeout;
     this.scope             = scope;
     this.IsolationLevel    = isolationLevel;
     this.SystemTransaction = Transaction.Current;
 }
Esempio n. 2
0
        public virtual void Create(DatabaseCreationOptions options)
        {
            using (var scope = new DataAccessScope(DataAccessIsolationLevel.Unspecified, DataAccessScopeOptions.RequiresNew, TimeSpan.FromMinutes(10)))
            {
                this.GetCurrentSqlDatabaseContext().SchemaManager.CreateDatabaseAndSchema(options);

                scope.Complete();
            }
        }
Esempio n. 3
0
        public DataAccessScope(DataAccessIsolationLevel isolationLevel, DataAccessScopeOptions options, TimeSpan timeout)
        {
            this.IsolationLevel = isolationLevel;
            var currentTransaction = DataAccessTransaction.Current;

            this.options = options;

            switch (options)
            {
            case DataAccessScopeOptions.Required:
                if (currentTransaction == null)
                {
                    this.isRoot      = true;
                    this.transaction = new DataAccessTransaction(isolationLevel, this, timeout);
                    DataAccessTransaction.Current = this.transaction;
                }
                else
                {
                    this.transaction         = currentTransaction;
                    this.outerScope          = currentTransaction.scope;
                    currentTransaction.scope = this;
                }
                break;

            case DataAccessScopeOptions.RequiresNew:
                this.isRoot      = true;
                this.outerScope  = currentTransaction?.scope;
                this.transaction = new DataAccessTransaction(isolationLevel, this, timeout);
                DataAccessTransaction.Current = this.transaction;
                break;

            case DataAccessScopeOptions.Suppress:
                if (currentTransaction != null)
                {
                    this.outerScope = currentTransaction.scope;
                    DataAccessTransaction.Current = null;
                }
                break;
            }
        }