Beispiel #1
0
        private static DalBase CreateDalBase(string connNameOrString)
        {
            //ABCConn
            DalBase db = GetDalBaseBy(ConnObject.Create(connNameOrString));

            if (!string.IsNullOrEmpty(connNameOrString) && db.ConnObj.Master.ConnName.ToLower() != connNameOrString.ToLower() && connNameOrString.EndsWith("Conn"))//需要切换配置。
            {
                //Conn  A库
                //BConn  xxx 找不到时,找默认库。
                DBResetResult result = db.ChangeDatabase(connNameOrString.Substring(0, connNameOrString.Length - 4));
                if (result == DBResetResult.Yes) // 写入缓存
                {
                    db.ConnObj.SaveToCache(connNameOrString);
                }
            }
            return(db);
        }
Beispiel #2
0
        //private const string SqlClient = "System.Data.SqlClient";
        //private const string OleDb = "System.Data.OleDb";
        //private const string OracleClient = "System.Data.OracleClient";
        //private const string SQLiteClient = "System.Data.SQLite";
        //private const string MySqlClient = "MySql.Data.MySqlClient";
        //private const string SybaseClient = "Sybase.Data.AseClient";
        //private const string PostgreClient = "System.Data.NpgSqlClient";
        //private const string TxtClient = "CYQ.Data.TxtClient";
        //private const string XmlClient = "CYQ.Data.XmlClient";
        //private const string XHtmlClient = "CYQ.Data.XHtmlClient";

        /// <summary>
        /// ¼òµ¥¹¤³§£¨Factory Method£©
        /// </summary>
        public static DalBase CreateDal(string connNameOrString)
        {
            //ABCConn
            DalBase db = GetDalBaseBy(ConnObject.Create(connNameOrString));

            if (db.ConnObj.Master.ConnName != connNameOrString && connNameOrString.EndsWith("Conn"))//ÐèÒªÇл»ÅäÖá£
            {
                //Conn  A¿â
                //BConn  xxx ÕÒ²»µ½Ê±£¬ÕÒĬÈÏ¿â¡£
                DBResetResult result = db.ChangeDatabase(connNameOrString.Substring(0, connNameOrString.Length - 4));
                if (result == DBResetResult.Yes) // дÈ뻺´æ
                {
                    db.ConnObj.SaveToCache(connNameOrString);
                }
            }
            return(db);
        }