Exemple #1
0
        private void DisposeAllSqlDatabaseContexts()
        {
            DataAccessModelTransactionManager.GetAmbientTransactionManager(this).FlushConnections();

            foreach (var context in this.sqlDatabaseContextsByCategory
                     .SelectMany(c => this.sqlDatabaseContextsByCategory.Values)
                     .SelectMany(c => c.DatabaseContexts))
            {
                context.Dispose();
            }
        }
        /// <summary>
        /// Gets the <see cref="DataAccessModelTransactionManager "/> for the current <see cref="Shaolinq.DataAccessModel"/> for the current thread.
        /// </summary>
        /// <remarks>
        /// The framework does not support accessing objects created within different transactions
        /// from other transactions. For each Transaction there may be more than one attached
        /// <see cref="TransactionContext"/> (one for each thread that participates in the transaction).
        /// </remarks>
        public static DataAccessModelTransactionManager GetAmbientTransactionManager(DataAccessModel dataAccessModel)
        {
            DataAccessModelTransactionManager retval;
            var transactionManagers = ambientTransactionManagers.Value;

            if (!transactionManagers.TryGetValue(dataAccessModel, out retval))
            {
                retval = new DataAccessModelTransactionManager(dataAccessModel);

                transactionManagers[dataAccessModel] = retval;
            }

            return(retval);
        }
Exemple #3
0
        /// <summary>
        /// Gets the <see cref="DataAccessModelTransactionManager "/> for the current <see cref="Shaolinq.DataAccessModel"/> for the current thread.
        /// </summary>
        /// <remarks>
        /// The framework does not support accessing objects created within different transactions
        /// from other transactions. For each Transaction there may be more than one attached
        /// <see cref="TransactionContext"/> (one for each thread that participates in the transaction).
        /// </remarks>
        public static DataAccessModelTransactionManager GetAmbientTransactionManager(DataAccessModel dataAccessModel)
        {
            DataAccessModelTransactionManager retval;
            var transactionManagers = AmbientTransactionManagers;

            if (transactionManagers == null)
            {
                transactionManagers = new Dictionary <DataAccessModel, DataAccessModelTransactionManager>();

                DataAccessModelTransactionManager.AmbientTransactionManagers = transactionManagers;
            }

            if (!transactionManagers.TryGetValue(dataAccessModel, out retval))
            {
                retval = new DataAccessModelTransactionManager(dataAccessModel);

                transactionManagers[dataAccessModel] = retval;
            }

            return(retval);
        }
        /// <summary>
        /// Gets the <see cref="DataAccessModelTransactionManager "/> for the current <see cref="Shaolinq.DataAccessModel"/> for the current thread.
        /// </summary>
        /// <remarks>
        /// The framework does not support accessing objects created within different transactions
        /// from other transactions. For each Transaction there may be more than one attached
        /// <see cref="TransactionContext"/> (one for each thread that participates in the transaction).
        /// </remarks>
        public static DataAccessModelTransactionManager GetAmbientTransactionManager(DataAccessModel dataAccessModel)
        {
            DataAccessModelTransactionManager retval;
            var transactionManagers = ambientTransactionManagers.Value;

            if (!transactionManagers.TryGetValue(dataAccessModel, out retval))
            {
                retval = new DataAccessModelTransactionManager(dataAccessModel);

                transactionManagers[dataAccessModel] = retval;
            }

            return retval;
        }
Exemple #5
0
 public SqlTransactionalCommandsContext GetCurrentSqlDatabaseTransactionContext()
 {
     return(DataAccessModelTransactionManager.GetAmbientTransactionManager(this).GetCurrentContext(true).GetCurrentDatabaseTransactionContext(this.GetCurrentSqlDatabaseContext()));
 }
Exemple #6
0
 public DataAccessObjectDataContext GetCurrentDataContext(bool forWrite)
 {
     return(DataAccessModelTransactionManager.GetAmbientTransactionManager(this).GetCurrentContext(forWrite).CurrentDataContext);
 }
        /// <summary>
        /// Gets the <see cref="DataAccessModelTransactionManager "/> for the current <see cref="Shaolinq.DataAccessModel"/> for the current thread.
        /// </summary>
        /// <remarks>
        /// The framework does not support accessing objects created within different transactions
        /// from other transactions. For each Transaction there may be more than one attached
        /// <see cref="TransactionContext"/> (one for each thread that participates in the transaction).
        /// </remarks>
        public static DataAccessModelTransactionManager GetAmbientTransactionManager(DataAccessModel dataAccessModel)
        {
            DataAccessModelTransactionManager retval;
            var transactionManagers = AmbientTransactionManagers;

            if (transactionManagers == null)
            {
                transactionManagers = new Dictionary<DataAccessModel, DataAccessModelTransactionManager>();

                DataAccessModelTransactionManager.AmbientTransactionManagers = transactionManagers;
            }

            if (!transactionManagers.TryGetValue(dataAccessModel, out retval))
            {
                retval = new DataAccessModelTransactionManager(dataAccessModel);

                transactionManagers[dataAccessModel] = retval;
            }

            return retval;
        }