/// <summary> /// Creates the db provider. /// </summary> /// <param name="dt">The dt.</param> /// <param name="connStr">The conn STR.</param> /// <returns>The db provider.</returns> private DbProvider CreateDbProvider(DBType dbType, string connStr) { DbProvider provider = null; switch (dbType) { case DBType.SqlServer: provider = ProviderFactory.CreateDbProvider(null, typeof(SqlServerProvider).FullName, connStr, dbType); break; case DBType.Oracle: provider = ProviderFactory.CreateDbProvider(null, typeof(OracleProvider).FullName, connStr, dbType); break; case DBType.MySql: provider = ProviderFactory.CreateDbProvider(null, typeof(MySqlProvider).FullName, connStr, dbType); break; case DBType.SQLite: provider = ProviderFactory.CreateDbProvider(null, typeof(SqliteProvider).FullName, connStr, dbType); break; case DBType.Access: provider = ProviderFactory.CreateDbProvider(null, typeof(AccessProvider).FullName, connStr, dbType); break; } if (provider != null) { provider.DatabaseType = dbType; } return(provider); }
/// <summary> /// 获取驱动 /// </summary> /// <returns></returns> private DbProvider GetDbProvider(string connectionName) { return(ProviderFactory.CreateDbProvider(connectionName, GetProviderType())); }
/// <summary> /// 获取驱动 /// </summary> /// <returns></returns> private DbProvider GetDbProviderFromConnectionString(string connectionString) { return(ProviderFactory.CreateDbProvider(GetProviderType(), connectionString)); }
/// <summary> /// 创建连接会话,指定链接字符串 /// </summary> /// <returns></returns> private DbSession GetSession(string connectionString) { DbProvider dbProvider = ProviderFactory.CreateDbProvider(GetProviderType(), connectionString); return(new DbSession(dbProvider)); }