示例#1
0
        public override DbContext CreateDbContext <TDbContext>(string connectionString, IDbContextResolver dbContextResolver)
        {
            var dtx = base.CreateDbContext <TDbContext>(connectionString, dbContextResolver);

            var currentIsolation = (IsolationLevel)SafeConvert.ToEnum(typeof(IsolationLevel), (object)Options.IsolationLevel, IsolationLevel.ReadUncommitted);

            if (Options.IsTransactional == true && isBeginTransaction)
            {
                dataBaseTransactions.Add(new DataBaseTransaction()
                {
                    Transaction = dtx.Database.BeginTransaction(currentIsolation),
                    dbContext   = dtx,
                    isCommit    = false
                });
            }
            return(dtx);
        }