Пример #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="keyName"></param>
 /// <returns></returns>
 public static SQLServer GetInstance(string keyName)
 {
     if (null != SQLServer.regDict && SQLServer.regDict.ContainsKey(keyName))
     {
         SQLServer inst = new SQLServer();
         inst.keyName          = keyName;
         inst.connectionString = SQLServer.regDict[keyName];
         inst.UpdateSysObject(true);
         return(inst);
     }
     return(null);
 }
Пример #2
0
        /// <summary>
        /// 获取一个可操作性的实例
        /// </summary>
        /// <param name="type"></param>
        /// <param name="exData"></param>
        /// <returns></returns>
        public static DataStorage GetInstance(DBType dbType, object exData = null)
        {
            DataStorage.Register();
            DataStorage inst = new DataStorage();

            if (DBType.MongoDB == dbType)
            {
                inst.mongo = MongoDB.GetInst("mongodb");
            }
            else if (DBType.SQLServer == dbType)
            {
                inst.sqlserver = SQLServer.GetInstance("sqlserver");
            }
            return(inst);
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="keyName"></param>
        /// <param name="dbType">mongo,sqlserver,mysql,redis</param>
        /// <returns></returns>
        public static DataStorage GetInstance(string keyName = "140", string dbType = "mongo")
        {
            DataStorage.Register();
            DataStorage inst = new DataStorage();

            if ("mongo" == dbType)
            {
                inst.mongo = MongoDB.GetInst(keyName);
            }
            else if ("sqlserver" == dbType)
            {
                inst.sqlserver = SQLServer.GetInstance(keyName);
                inst.sqlserver.UpdateSysObject(true);
            }
            return(inst);
        }