Exemplo n.º 1
0
 public void MT_Transaction_GetCurrentTransactionBlock()
 {
     using (var tranOuter = RF.TransactionScope(DbSettingNames.RafyPlugins))
     {
         using (var tranInner1 = RF.TransactionScope(DbSettingNames.RafyPlugins))
         {
             var currentScope = LocalTransactionBlock.GetCurrentTransactionBlock(DbSetting.FindOrCreate(DbSettingNames.RafyPlugins));
             Assert.AreEqual(currentScope, tranInner1);
         }
     }
 }
        public static TransactionDependentConnectionManager GetManager(DbSetting dbSetting)
        {
            var res = new TransactionDependentConnectionManager();

            res._block = LocalTransactionBlock.GetWholeScope(dbSetting.Database);
            if (res._block != null)
            {
                res._connection = res._block.WholeTransaction.Connection;
            }
            else
            {
                //没有定义事务范围时,无需共享连接。
                res._connection = dbSetting.CreateConnection();
                res._connection.Open();
            }

            res._dbSetting = dbSetting;

            return(res);
        }