/// <summary>
 /// Initializes a new instance of the <see cref="DatabaseReader"/> class from a DbConnection.
 /// </summary>
 /// <param name="connection">The connection.</param>
 public DatabaseReader(System.Data.Common.DbConnection connection)
 {
     var name = connection.GetType().Namespace;
     _db = new DatabaseSchema(connection.ConnectionString, name);
     _schemaParameters = new SchemaParameters(connection) {DatabaseSchema = _db};
     _readerAdapter = ReaderAdapterFactory.Create(_schemaParameters);
 }
 /// <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)
 {
     if (connectionString == null) throw new ArgumentNullException("connectionString");
     _schemaParameters = new SchemaParameters(connectionString, sqlType);
     _readerAdapter = ReaderAdapterFactory.Create(_schemaParameters);
     //_schemaReader = SchemaReaderFactory.Create(connectionString, sqlType);
     _db = new DatabaseSchema(connectionString, _schemaParameters.ProviderName);
     _schemaParameters.DatabaseSchema = _db;
 }
 public TableBuilder(ReaderAdapter readerAdapter)
 {
     _readerAdapter = readerAdapter;
 }
 public ProcedureBuilder(ReaderAdapter readerAdapter, DatabaseSchema databaseSchema, Exclusions exclusions)
 {
     _readerAdapter = readerAdapter;
     _databaseSchema = databaseSchema;
     _exclusions = exclusions;
 }
 public ViewBuilder(ReaderAdapter readerAdapter, Exclusions exclusions)
 {
     _readerAdapter = readerAdapter;
     _exclusions = exclusions;
 }
Exemple #6
0
        public static ReaderAdapter Create(SchemaParameters schemaParameters)
        {
            ReaderAdapter schemaReader = null;

            switch (schemaParameters.SqlType)
            {
            case SqlType.SqlServer:
                return(new SqlServerAdapter(schemaParameters));

            case SqlType.Oracle:
                schemaReader = new OracleAdapter(schemaParameters);
                break;

            case SqlType.SQLite:
                schemaReader = new SqLiteAdapter(schemaParameters);
                break;

            case SqlType.PostgreSql:
                schemaReader = new PostgreSqlAdapter(schemaParameters);
                break;

            case SqlType.MySql:
                schemaReader = new MySqlAdapter(schemaParameters);
                break;

            case SqlType.SqlServerCe:
                schemaReader = new SqlServerCeAdapter(schemaParameters);
                break;

            default:
                //var providerName = schemaParameters.ProviderName;
                //all the other types
                //if (providerName.Equals("Ingres.Client", StringComparison.OrdinalIgnoreCase))
                //{
                //    schemaReader = new IngresSchemaReader(connectionString, providerName);
                //}
                //else if (providerName.Equals("iAnyWhere.Data.SQLAnyWhere", StringComparison.OrdinalIgnoreCase))
                //{
                //    schemaReader = new SybaseAsaSchemaReader(connectionString, providerName);
                //}
                //else if (providerName.Equals("Sybase.Data.AseClient", StringComparison.OrdinalIgnoreCase))
                //{
                //    schemaReader = new SybaseAseSchemaReader(connectionString, providerName);
                //}
                //else if (providerName.Equals("iAnyWhere.Data.UltraLite", StringComparison.OrdinalIgnoreCase))
                //{
                //    schemaReader = new SybaseUltraLiteSchemaReader(connectionString, providerName);
                //}
                //else if (providerName.Equals("System.Data.OleDb", StringComparison.OrdinalIgnoreCase))
                //{
                //    schemaReader = new OleDbSchemaReader(connectionString, providerName);
                //}
                //else if (providerName.Equals("System.Data.VistaDB", StringComparison.OrdinalIgnoreCase))
                //{
                //    schemaReader = new VistaDbSchemaReader(connectionString, providerName);
                //}
                //else if (providerName.Equals("IBM.Data.DB2.iSeries", StringComparison.OrdinalIgnoreCase))
                //{
                //    schemaReader = new Db2ISeriesSchemaReader(connectionString, providerName);
                //}
                //else if (providerName.Equals("FirebirdSql.Data.FirebirdClient", StringComparison.OrdinalIgnoreCase))
                //{
                //    schemaReader = new FirebirdSqlSchemaReader(connectionString, providerName);
                //}

                break;
            }
            if (schemaReader == null)
            {
#if !COREFX
                schemaReader = new DbProviderReaderAdapter(schemaParameters);
#else
                schemaReader = new ReaderAdapter(schemaParameters);
#endif
            }
            return(schemaReader);
        }
        public static ReaderAdapter Create(SchemaParameters schemaParameters)
        {
            ReaderAdapter schemaReader = null;
            switch (schemaParameters.SqlType)
            {
                case SqlType.SqlServer:
                    return new SqlServerAdapter(schemaParameters);
                case SqlType.Oracle:
                    schemaReader = new OracleAdapter(schemaParameters);
                    break;
                case SqlType.SQLite:
                    schemaReader = new SqLiteAdapter(schemaParameters);
                    break;
                case SqlType.PostgreSql:
                    schemaReader = new PostgreSqlAdapter(schemaParameters);
                    break;
                case SqlType.MySql:
                    schemaReader = new MySqlAdapter(schemaParameters);
                    break;
                case SqlType.SqlServerCe:
                    schemaReader = new SqlServerCeAdapter(schemaParameters);
                    break;

                default:
                    //var providerName = schemaParameters.ProviderName;
                    //all the other types
                    //if (providerName.Equals("Ingres.Client", StringComparison.OrdinalIgnoreCase))
                    //{
                    //    schemaReader = new IngresSchemaReader(connectionString, providerName);
                    //}
                    //else if (providerName.Equals("iAnyWhere.Data.SQLAnyWhere", StringComparison.OrdinalIgnoreCase))
                    //{
                    //    schemaReader = new SybaseAsaSchemaReader(connectionString, providerName);
                    //}
                    //else if (providerName.Equals("Sybase.Data.AseClient", StringComparison.OrdinalIgnoreCase))
                    //{
                    //    schemaReader = new SybaseAseSchemaReader(connectionString, providerName);
                    //}
                    //else if (providerName.Equals("iAnyWhere.Data.UltraLite", StringComparison.OrdinalIgnoreCase))
                    //{
                    //    schemaReader = new SybaseUltraLiteSchemaReader(connectionString, providerName);
                    //}
                    //else if (providerName.Equals("System.Data.OleDb", StringComparison.OrdinalIgnoreCase))
                    //{
                    //    schemaReader = new OleDbSchemaReader(connectionString, providerName);
                    //}
                    //else if (providerName.Equals("System.Data.VistaDB", StringComparison.OrdinalIgnoreCase))
                    //{
                    //    schemaReader = new VistaDbSchemaReader(connectionString, providerName);
                    //}
                    //else if (providerName.Equals("IBM.Data.DB2.iSeries", StringComparison.OrdinalIgnoreCase))
                    //{
                    //    schemaReader = new Db2ISeriesSchemaReader(connectionString, providerName);
                    //}
                    //else if (providerName.Equals("FirebirdSql.Data.FirebirdClient", StringComparison.OrdinalIgnoreCase))
                    //{
                    //    schemaReader = new FirebirdSqlSchemaReader(connectionString, providerName);
                    //}

                    break;
            }
            if (schemaReader == null)
            {
            #if !COREFX
                schemaReader = new DbProviderReaderAdapter(schemaParameters);
            #else
                schemaReader = new ReaderAdapter(schemaParameters);
            #endif
            }
            return schemaReader;
        }
        /// <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)
        {
            if (databaseSchema == null) throw new ArgumentNullException("databaseSchema");
            if (databaseSchema.ConnectionString == null) throw new ArgumentException("No connectionString");

            _schemaParameters = new SchemaParameters(databaseSchema.ConnectionString, databaseSchema.Provider);
            _schemaParameters.DatabaseSchema = databaseSchema;
            _schemaParameters.Owner = databaseSchema.Owner;
            _readerAdapter = ReaderAdapterFactory.Create(_schemaParameters);
            _db = databaseSchema;
        }