/// <summary> /// 获取加载器 /// </summary> /// <returns></returns> public static IAdapterLoader GetLoader(string key) { IAdapterLoader ret = null; if (key.Equals("Sql2K", StringComparison.CurrentCultureIgnoreCase)) { ret = new Buffalo.DB.DataBaseAdapter.SqlServer2KAdapter.AdapterLoader(); } else if (key.Equals("Sql2K5", StringComparison.CurrentCultureIgnoreCase)) { ret = new Buffalo.DB.DataBaseAdapter.SqlServer2K5Adapter.AdapterLoader(); } else if (key.Equals("Sql2K8", StringComparison.CurrentCultureIgnoreCase)) { ret = new Buffalo.DB.DataBaseAdapter.SqlServer2K8Adapter.AdapterLoader(); } else if (key.Equals("Oracle9", StringComparison.CurrentCultureIgnoreCase)) { ret = new Buffalo.DB.DataBaseAdapter.Oracle9Adapter.AdapterLoader(); } else if (key.Equals("Access", StringComparison.CurrentCultureIgnoreCase)) { ret = new Buffalo.DB.DataBaseAdapter.AccessAdapter.AdapterLoader(); } else { Type loaderType = GetAdapterLoader(key); ret = Activator.CreateInstance(loaderType) as IAdapterLoader; } return(ret); }
/// <summary> /// Get AdapterLoader Which Is Adapte To The Protocol In Config /// </summary> /// <returns></returns> public static IAdapterLoader GetAdapterLoader() { if (adapterLoader == null) { adapterLoader = (IAdapterLoader)GetServiceEntity(); } return(adapterLoader); }
/// <summary> /// 初始化数据库适配器 /// </summary> private void InitAdapters() { IAdapterLoader loader = GetLoader(DbType); if (loader == null) { throw new Exception("不支持数据库类型:" + DbType); } _curAggregateFunctions = loader.AggregateFunctions; _curCommonFunctions = loader.CommonFunctions; _curConvertFunctions = loader.ConvertFunctions; _curDbAdapter = loader.DbAdapter; _curDBStructure = loader.DBStructure; _curMathFunctions = loader.MathFunctions; }