private DatabaseReader(string name, string connectionString, SchemaParameters schemaParameters)
 {
     _db = new DatabaseSchema(connectionString, name);
     _schemaParameters = schemaParameters;
     _schemaParameters.DatabaseSchema = _db;
     _readerAdapter = ReaderAdapterFactory.Create(_schemaParameters);
 }
        /// <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;
 }
        /// <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>
        /// <param name="additionalParameters"></param>
        public DatabaseReader(string connectionString, SqlType sqlType, int commandTimeout, IAdditionalProperties additionalParameters = null)
        {
            if (connectionString == null)
            {
                throw new ArgumentNullException("connectionString");
            }
            _schemaParameters = new SchemaParameters(connectionString, sqlType);
            _readerAdapter    = ReaderAdapterFactory.Create(_schemaParameters, commandTimeout);
            _readerAdapter.AdditionalParameters = additionalParameters;

            //_schemaReader = SchemaReaderFactory.Create(connectionString, sqlType);
            _db = new DatabaseSchema(connectionString, _schemaParameters.ProviderName);
            _schemaParameters.DatabaseSchema = _db;
        }
        /// <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;
        }
示例#6
0
        /// <summary>
        /// Gets all query columns
        /// </summary>
        public IList <DatabaseColumn> GetQueryColumns(DbConnection connection, string sql)
        {
            if (connection == null)
            {
                throw new ArgumentNullException(nameof(connection));
            }
            var schemaParameters = new SchemaParameters(connection);
            var readerAdapter    = ReaderAdapterFactory.Create(schemaParameters);
            var types            = readerAdapter.DataTypes();

            using (var cmd = connection.CreateCommand())
            {
                cmd.CommandText = sql;

                return(GetQueryColumns(cmd, types));
            }
        }
        /// <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>
        /// <param name="commandTimeout"></param>
        /// <param name="additionalParameters"></param>
        public DatabaseReader(DatabaseSchema databaseSchema, int commandTimeout, IAdditionalProperties additionalParameters = null)
        {
            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, commandTimeout);
            _readerAdapter.AdditionalParameters = additionalParameters;
            _db = databaseSchema;
        }