/// <summary>
        /// トランザクションを新規に開始する内部メソッド
        /// </summary>
        /// <param name="isSuperRootTx"></param>
        /// <param name="isolationLevel"></param>
        /// <param name="memberName"></param>
        /// <param name="sourceFilePath"></param>
        /// <param name="sourceLineNumber"></param>
        /// <returns></returns>
        private async Task <OneWorldDbTransactionScope <TDbContext> > BeginTranRequiresNewInternalAsync(
            bool isSuperRootTx,
            IsolationLevel?isolationLevel = null,
            string memberName             = "",
            string sourceFilePath         = "",
            int sourceLineNumber          = 0)
        {
            var transactionNumber = isSuperRootTx ? -1 : _transactions.Count;
            var firstTran         =
                OneWorldDbTransaction <TDbContext> .CreateOneWorldDbTransaction(
                    transactionId : Guid.NewGuid(),
                    transactionNumber : transactionNumber,
                    dbConnection : _dbConnectionFactory.Invoke(_connectionString),
                    isolationLevel : isolationLevel ?? IsolationLevel.ReadCommitted,
                    oneWorldDbClientManager : this,
                    dbContextFactory : _dbContextFactory,
                    logger : _loggerTx);

            _logger.LogInformation($" RequiresNew:isSuperRootTx=`{isSuperRootTx}`,TransactionNumber=`{firstTran.TransactionNumber}`/TransactionId=`{firstTran.TransactionId}`/IsolationLevel=`{firstTran.IsolationLevel}`");

            if (!_transactions.TryAdd(firstTran.TransactionId, firstTran))
            {
                throw new InvalidProgramException($"duplicate transaction id {firstTran.TransactionId}");
            }

            _publishedTransactionStack.Push(firstTran.TransactionId);

            return(await firstTran.CreateTransactionScopeAsync(memberName, sourceFilePath, sourceLineNumber));
        }
Exemplo n.º 2
0
 Create(
     IDbConnection dbConnection,
     IDbTransaction dbTransaction,
     DbContext dbContext,
     OneWorldDbTransaction <TDbContext> oneWorldDbTransaction,
     ILogger <OneWorldDbTransaction <TDbContext> > logger,
     string memberName     = "",
     string sourceFilePath = "",
     int sourceLineNumber  = 0)
 {
     return(new OneWorldDbTransactionScope <TDbContext>(
                dbConnection,
                dbTransaction,
                dbContext,
                oneWorldDbTransaction,
                logger,
                memberName,
                sourceFilePath,
                sourceLineNumber));
 }
Exemplo n.º 3
0
        private OneWorldDbTransactionScope(
            IDbConnection dbConnection,
            IDbTransaction dbTransaction,
            DbContext dbContext,
            OneWorldDbTransaction <TDbContext> oneWorldDbTransaction,
            ILogger <OneWorldDbTransaction <TDbContext> > logger,
            string memberName     = "",
            string sourceFilePath = "",
            int sourceLineNumber  = 0)
        {
            DbConnection           = dbConnection;
            DbTransaction          = dbTransaction;
            DbContext              = dbContext;
            _oneWorldDbTransaction = oneWorldDbTransaction;

            _logger = logger;

            _memberName       = memberName;
            _sourceFilePath   = sourceFilePath;
            _sourceLineNumber = sourceLineNumber;
        }