コード例 #1
0
        private static System.Data.IsolationLevel GetIsolationLevel(Framework.Common.Enums.IsolationLevel isolationLevel)
        {
            switch (isolationLevel)
            {
            case Framework.Common.Enums.IsolationLevel.Unspecified:
                return(System.Data.IsolationLevel.Unspecified);

            case Framework.Common.Enums.IsolationLevel.RepeatableRead:
                return(System.Data.IsolationLevel.RepeatableRead);

            case Framework.Common.Enums.IsolationLevel.ReadCommitted:
                return(System.Data.IsolationLevel.ReadCommitted);

            case Framework.Common.Enums.IsolationLevel.ReadUncommitted:
                return(System.Data.IsolationLevel.ReadUncommitted);

            case Framework.Common.Enums.IsolationLevel.Snapshot:
                return(System.Data.IsolationLevel.Snapshot);

            case Framework.Common.Enums.IsolationLevel.Chaos:
                return(System.Data.IsolationLevel.Chaos);

            default:
                return(System.Data.IsolationLevel.Serializable);
            }
        }
コード例 #2
0
        public ITransaction BegingGlobalTransaction(Framework.Common.Enums.IsolationLevel isolationLevel = Framework.Common.Enums.IsolationLevel.ReadCommitted)
        {
            if (In <Transaction>())
            {
                throw new DataAccessException("Cannot enlist in the transaction because a local transaction is in progress on the connection.  Finish local transaction and retry.");
            }
            var context = Get <GlobalTransaction>();

            context.Set(DbContexts, GetGlobalIsolationLevel(isolationLevel));
            return(context);
        }
コード例 #3
0
        public ITransaction BeginTransaction(Framework.Common.Enums.IsolationLevel isolationLevel = Framework.Common.Enums.IsolationLevel.ReadCommitted)
        {
            Context transactionContext;

            if (!Contexts.TryGetValue(typeof(Transaction), out transactionContext))
            {
                if (DbContexts.Count == 0)
                {
                    var defaultContext = DependencyResolver.Get <DbContext>();
                    DbContexts.Add(defaultContext.GetType(), defaultContext);
                }
                transactionContext = Get <Transaction>().Set(DbContexts, GetIsolationLevel(isolationLevel));
            }
            return((ITransaction)transactionContext);
        }