/// <summary> /// 分库路由器,如果操作存在事务,返回的DB连接已在事务中 /// 数据库主从集群 /// </summary> /// <param name="ODASql"></param> /// <returns></returns> private IDBAccess DatabaseRouting(ODAScript ODASql) { ODAConnect conn = GetConnect(ODASql); if (_Tran == null) { return(ODAContext.NewDBConnect(conn.DBtype, conn.ConnectionString)); } else { this.CheckTransaction(ODASql); if (_Tran.TransDB.ContainsKey(conn.ConnectionString)) { return(_Tran.TransDB[conn.ConnectionString]); } else { IDBAccess DBA = ODAContext.NewDBConnect(conn.DBtype, conn.ConnectionString); DBA.BeginTransaction(); _Tran.DoCommit += DBA.Commit; _Tran.RollBacking += DBA.RollBack; _Tran.TransDB.Add(conn.ConnectionString, DBA); return(DBA); } } }