Configure() public static method

通过缺省的连接字串配置创建DbConfiguration对象(当且仅当配置文件中只有一个数据库连接字符串配置时才能使用)
public static Configure ( ) : DbConfiguration
return DbConfiguration
コード例 #1
0
 /// <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());
 }
コード例 #2
0
        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);
        }
コード例 #3
0
 /// <summary>
 ///  配置Oracle ODP
 /// </summary>
 /// <param name="connectionString"></param>
 /// <returns></returns>
 public static DbConfiguration ConfigureOracleODP(string connectionString)
 {
     return(DbConfiguration.Configure(connectionString, DbProviderNames.Oracle_ODP));
 }
コード例 #4
0
 /// <summary>
 /// 配置SqlServer
 /// </summary>
 /// <param name="connectionString"></param>
 /// <returns></returns>
 public static DbConfiguration ConfigureSqlServer(string connectionString)
 {
     return(DbConfiguration.Configure(connectionString, DbProviderNames.SqlServer));
 }
コード例 #5
0
 /// <summary>
 /// 配置MySQL
 /// </summary>
 /// <param name="connectionString"></param>
 /// <returns></returns>
 public static DbConfiguration ConfigureMySQL(string connectionString)
 {
     return(DbConfiguration.Configure(connectionString, DbProviderNames.MySQL));
 }
コード例 #6
0
 /// <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));
 }
コード例 #7
0
 /// <summary>
 /// 配置SQLite
 /// </summary>
 /// <param name="databaseFile"></param>
 /// <returns></returns>
 public static DbConfiguration ConfigureSQLite(string databaseFile)
 {
     return(DbConfiguration.Configure(BuildSQLiteConnectionString(databaseFile), DbProviderNames.SQLite));
 }
コード例 #8
0
 /// <summary>
 /// 配置SQLExpress
 /// </summary>
 /// <param name="databaseFile"></param>
 /// <returns></returns>
 public static DbConfiguration ConfigureSQLExpress(string databaseFile)
 {
     return(DbConfiguration.Configure(BuildSQLExpressConnectionString(databaseFile), DbProviderNames.SqlServer));
 }
コード例 #9
0
 /// <summary>
 /// 配置SqlCe4
 /// </summary>
 /// <param name="databaseFile"></param>
 /// <returns></returns>
 public static DbConfiguration ConfigureSqlCe4(string databaseFile)
 {
     return(DbConfiguration.Configure(BuildSqlCeConnectionString(databaseFile), DbProviderNames.SqlCe40));
 }
コード例 #10
0
 /// <summary>
 /// 配置Access
 /// </summary>
 /// <param name="databaseFile"></param>
 /// <returns></returns>
 public static DbConfiguration ConfigureAccess(string databaseFile)
 {
     return(DbConfiguration.Configure(BuildAccessConnectionString(databaseFile), DbProviderNames.Oledb));
 }