/// <summary> /// Initializes a new instance of the <see cref="DatabaseReader"/> class. For Oracle, use the overload. /// </summary> /// <param name="connectionString">The connection string.</param> /// <param name="providerName">Name of the provider.</param> public DatabaseReader(string connectionString, string providerName) { _sr = new SchemaExtendedReader(connectionString, providerName); if (!string.IsNullOrEmpty(providerName)) { var type = ProviderToSqlType.Convert(providerName); switch (type) { case SqlType.Oracle: _sr = new OracleSchemaReader(connectionString, providerName); break; case SqlType.SqlServer: _sr = new SqlServerSchemaReader(connectionString, providerName); break; case SqlType.SqlServerCe: _sr = new SqlServerCeSchemaReader(connectionString, providerName); break; case SqlType.MySql: _sr = new MySqlSchemaReader(connectionString, providerName); break; case SqlType.PostgreSql: _sr = new PostgreSqlSchemaReader(connectionString, providerName); break; case SqlType.Db2: _sr = new Db2SchemaReader(connectionString, providerName); break; } if (providerName.Equals("Ingres.Client", StringComparison.OrdinalIgnoreCase)) { _sr = new IngresSchemaReader(connectionString, providerName); } else if (providerName.Equals("iAnyWhere.Data.SQLAnyWhere", StringComparison.OrdinalIgnoreCase)) { _sr = new SybaseAsaSchemaReader(connectionString, providerName); } else if (providerName.Equals("Sybase.Data.AseClient", StringComparison.OrdinalIgnoreCase)) { _sr = new SybaseAseSchemaReader(connectionString, providerName); } else if (providerName.Equals("iAnyWhere.Data.UltraLite", StringComparison.OrdinalIgnoreCase)) { _sr = new SybaseUltraLiteSchemaReader(connectionString, providerName); } else if (providerName.Equals("System.Data.OleDb", StringComparison.OrdinalIgnoreCase)) { _sr = new OleDbSchemaReader(connectionString, providerName); } else if (providerName.Equals("System.Data.VistaDB", StringComparison.OrdinalIgnoreCase)) { _sr = new VistaDbSchemaReader(connectionString, providerName); } } _db = new DatabaseSchema(connectionString, providerName); }
/// <summary> /// Initializes a new instance of the <see cref="DatabaseReader"/> class for one of the standard providers. /// </summary> /// <param name="connectionString">The connection string.</param> /// <param name="sqlType">Type of the SQL.</param> public DatabaseReader(string connectionString, SqlType sqlType) { switch (sqlType) { case SqlType.Oracle: _sr = new OracleSchemaReader(connectionString, "System.Data.OracleClient"); break; case SqlType.SqlServer: _sr = new SqlServerSchemaReader(connectionString, "System.Data.SqlClient"); break; case SqlType.SqlServerCe: _sr = new SqlServerCeSchemaReader(connectionString, "System.Data.SqlServerCe.4.0"); break; case SqlType.MySql: _sr = new MySqlSchemaReader(connectionString, "MySql.Data.MySqlClient"); break; case SqlType.PostgreSql: _sr = new PostgreSqlSchemaReader(connectionString, "Npgsql"); break; case SqlType.Db2: _sr = new Db2SchemaReader(connectionString, "IBM.Data.DB2"); break; case SqlType.SQLite: _sr = new SchemaExtendedReader(connectionString, "System.Data.SQLite"); break; default: throw new ArgumentOutOfRangeException("sqlType", "Not a recognized SqlType"); } _db = new DatabaseSchema(connectionString, _sr.ProviderName); }
/// <summary> /// Initializes a new instance of the <see cref="DatabaseReader"/> class using an existing <see cref="DatabaseSchema"/>. /// </summary> /// <param name="databaseSchema">The database schema. Can be a subclassed version.</param> public DatabaseReader(DatabaseSchema databaseSchema) { _schemaReader = SchemaReaderFactory.Create(databaseSchema.ConnectionString, databaseSchema.Provider); _schemaReader.Owner = databaseSchema.Owner; _db = databaseSchema; }
/// <summary> /// Initializes a new instance of the <see cref="DatabaseReader"/> class for one of the standard providers. /// </summary> /// <param name="connectionString">The connection string.</param> /// <param name="sqlType">Type of the SQL.</param> public DatabaseReader(string connectionString, SqlType sqlType) { _schemaReader = SchemaReaderFactory.Create(connectionString, sqlType); _db = new DatabaseSchema(connectionString, _schemaReader.ProviderName); }