public static Configure ( ) : |
||
return |
/// <summary> /// 通过缺省的连接字串配置创建DbConfiguration对象(当且仅当配置文件中只有一个数据库连接字符串配置时才能使用) /// </summary> /// <returns></returns> public static DbConfiguration Configure() { if (System.Configuration.ConfigurationManager.ConnectionStrings.Count == 0) { throw new ConfigurationErrorsException(Res.ConnectionStringNoConfigException); } if (System.Configuration.ConfigurationManager.ConnectionStrings.Count != 1) { throw new ConfigurationErrorsException(Res.ConnectionStringNoConfigException); } return(DbConfiguration.Configure(System.Configuration.ConfigurationManager.ConnectionStrings[0].Name).MakeDefault()); }
internal static DbConfiguration Get(string dbConfigurationName) { Guard.NotNull(dbConfigurationName, "dbConfigurationName"); DbConfiguration cfg; items.TryGetValue(dbConfigurationName, out cfg); if (cfg == null) { //自动配置 cfg = DbConfiguration.Configure(dbConfigurationName); } return(cfg); }
/// <summary> /// 配置Oracle ODP /// </summary> /// <param name="connectionString"></param> /// <returns></returns> public static DbConfiguration ConfigureOracleODP(string connectionString) { return(DbConfiguration.Configure(connectionString, DbProviderNames.Oracle_ODP)); }
/// <summary> /// 配置SqlServer /// </summary> /// <param name="connectionString"></param> /// <returns></returns> public static DbConfiguration ConfigureSqlServer(string connectionString) { return(DbConfiguration.Configure(connectionString, DbProviderNames.SqlServer)); }
/// <summary> /// 配置MySQL /// </summary> /// <param name="connectionString"></param> /// <returns></returns> public static DbConfiguration ConfigureMySQL(string connectionString) { return(DbConfiguration.Configure(connectionString, DbProviderNames.MySQL)); }
/// <summary> /// 配置SQLite /// </summary> /// <param name="databaseFile"></param> /// <param name="password"></param> /// <param name="failIfMissing"></param> /// <returns></returns> public static DbConfiguration ConfigureSQLite(string databaseFile, string password, bool failIfMissing) { return(DbConfiguration.Configure(BuildSQLiteConnectionString(databaseFile, password, failIfMissing), DbProviderNames.SQLite)); }
/// <summary> /// 配置SQLite /// </summary> /// <param name="databaseFile"></param> /// <returns></returns> public static DbConfiguration ConfigureSQLite(string databaseFile) { return(DbConfiguration.Configure(BuildSQLiteConnectionString(databaseFile), DbProviderNames.SQLite)); }
/// <summary> /// 配置SQLExpress /// </summary> /// <param name="databaseFile"></param> /// <returns></returns> public static DbConfiguration ConfigureSQLExpress(string databaseFile) { return(DbConfiguration.Configure(BuildSQLExpressConnectionString(databaseFile), DbProviderNames.SqlServer)); }
/// <summary> /// 配置SqlCe4 /// </summary> /// <param name="databaseFile"></param> /// <returns></returns> public static DbConfiguration ConfigureSqlCe4(string databaseFile) { return(DbConfiguration.Configure(BuildSqlCeConnectionString(databaseFile), DbProviderNames.SqlCe40)); }
/// <summary> /// 配置Access /// </summary> /// <param name="databaseFile"></param> /// <returns></returns> public static DbConfiguration ConfigureAccess(string databaseFile) { return(DbConfiguration.Configure(BuildAccessConnectionString(databaseFile), DbProviderNames.Oledb)); }