示例#1
0
        public static void Get(
            Catalog catalog,
            Dictionary <string, UserTable> userTables,
            Dictionary <string, PrimaryKeyColumn> primaryKeyColumns,
            Dictionary <string, UniqueConstraintColumn> uniqueConstraintColumns,
            DbConnection connection,
            IMetadataScriptFactory metadataScriptFactory)
        {
            using (var command = connection.CreateCommand())
            {
                command.CommandText = metadataScriptFactory.ForeignKeys(catalog.ObjectName);
                using (var reader = command.ExecuteReader())
                {
                    if (!reader.HasRows)
                    {
                        reader.Close();
                        return;
                    }

                    Read(userTables, primaryKeyColumns, uniqueConstraintColumns, reader);

                    reader.Close();
                }
            }
        }
示例#2
0
        public static async Task GetAsync(
            Catalog catalog, Dictionary <string, UserTable> userTables,
            Dictionary <string, PrimaryKeyColumn> primaryKeyColumns,
            Dictionary <string, UniqueConstraintColumn> uniqueConstraintColumns,
            DbConnection connection,
            IMetadataScriptFactory metadataScriptFactory,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.ThrowIfCancellationRequested();
            using (var command = connection.CreateCommand())
            {
                command.CommandText = metadataScriptFactory.ForeignKeys(catalog.ObjectName);
                using (var reader = await command.ExecuteReaderAsync(cancellationToken))
                {
                    if (!reader.HasRows)
                    {
                        reader.Close();
                        return;
                    }

                    await ReadAsync(userTables, primaryKeyColumns, uniqueConstraintColumns, reader, cancellationToken);

                    reader.Close();
                }
            }
        }
        public static Dictionary <string, UniqueConstraintColumn> Get(
            Catalog catalog,
            Dictionary <string, UserTable> userTables,
            DbConnection connection,
            IMetadataScriptFactory metadataScriptFactory)
        {
            var uniqueConstraintColumns = new Dictionary <string, UniqueConstraintColumn>(StringComparer.OrdinalIgnoreCase);

            using (var command = connection.CreateCommand())
            {
                command.CommandText = metadataScriptFactory.UniqueConstraints(catalog.ObjectName);
                using (var reader = command.ExecuteReader())
                {
                    if (!reader.HasRows)
                    {
                        reader.Close();
                        return(uniqueConstraintColumns);
                    }

                    Read(userTables, uniqueConstraintColumns, reader);

                    reader.Close();
                }
            }

            return(uniqueConstraintColumns);
        }
        public static async Task <Dictionary <string, UniqueConstraintColumn> > GetAsync(
            Catalog catalog,
            Dictionary <string, UserTable> userTables,
            DbConnection connection,
            IMetadataScriptFactory metadataScriptFactory,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.ThrowIfCancellationRequested();
            var uniqueConstraintColumns = new Dictionary <string, UniqueConstraintColumn>(StringComparer.OrdinalIgnoreCase);

            using (var command = connection.CreateCommand())
            {
                command.CommandText = metadataScriptFactory.UniqueConstraints(catalog.ObjectName);
                using (var reader = await command.ExecuteReaderAsync(cancellationToken))
                {
                    if (!reader.HasRows)
                    {
                        reader.Close();
                        return(uniqueConstraintColumns);
                    }

                    await ReadAsync(userTables, uniqueConstraintColumns, reader, cancellationToken);

                    reader.Close();
                }
            }

            return(uniqueConstraintColumns);
        }
示例#5
0
        public static async Task BuildAsync(
            Catalog catalog,
            DbConnection connection,
            IMetadataScriptFactory metadataScriptFactory,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.ThrowIfCancellationRequested();
            var userTables = await GetAsync(catalog, connection, metadataScriptFactory, cancellationToken);

            if (userTables.Count == 0)
            {
                return;
            }

            await UserTableColumnAdapter.GetAsync(catalog, userTables, connection, metadataScriptFactory, cancellationToken);

            var primaryKeyColumns = await PrimaryKeyAdapter.GetAsync(catalog, userTables, connection, metadataScriptFactory, cancellationToken);

            var uniqueConstraintColumns = await UniqueConstraintAdapter.GetAsync(catalog, userTables, connection, metadataScriptFactory, cancellationToken);

            await ForeignKeyAdapter.GetAsync(catalog, userTables, primaryKeyColumns, uniqueConstraintColumns, connection, metadataScriptFactory, cancellationToken);

            await ComputedColumnsAdapter.GetAsync(catalog, userTables, connection, metadataScriptFactory, cancellationToken);

            await DefaultConstraintAdapter.GetAsync(catalog, userTables, connection, metadataScriptFactory, cancellationToken);

            await CheckConstraintAdapter.GetAsync(catalog, userTables, connection, metadataScriptFactory, cancellationToken);

            await IdentityColumnAdapter.GetAsync(catalog, userTables, connection, metadataScriptFactory, cancellationToken);

            await IndexAdapter.GetAsync(catalog, userTables, connection, metadataScriptFactory, cancellationToken);
        }
示例#6
0
 /// <summary>
 /// Fills all catalogs in the server object as well as building out the schemas
 /// and all objects in the database connection.
 /// </summary>
 /// <param name="server">The server to fill catalogs only.</param>
 /// <param name="connection">The open database connection to use.</param>
 /// <param name="metadataScriptFactory">The script factory determined by the database type.</param>
 public static void Build(
     Server server,
     DbConnection connection,
     IMetadataScriptFactory metadataScriptFactory)
 {
     Get(server, connection, metadataScriptFactory);
     foreach (var catalog in server.Catalogs)
     {
         SchemaAdapter.Build(catalog, connection, metadataScriptFactory);
     }
 }
示例#7
0
 /// <summary>
 /// Fills only specific catalogs in the server object as well as building out the schemas
 /// and all objects in the database connection.
 /// </summary>
 /// <param name="server">The server to fill catalogs only.</param>
 /// <param name="connection">The open database connection to use.</param>
 /// <param name="metadataScriptFactory">The script factory determined by the database type.</param>
 /// <param name="catalogs">The catalogs to filter.</param>
 public static void BuildSpecific(
     Server server,
     DbConnection connection,
     IMetadataScriptFactory metadataScriptFactory,
     IList <string> catalogs)
 {
     GetSpecific(server, connection, metadataScriptFactory, catalogs);
     foreach (var catalog in server.Catalogs)
     {
         SchemaAdapter.Build(catalog, connection, metadataScriptFactory);
     }
 }
示例#8
0
        /// <summary>
        /// Fills all catalogs in the server object as well as building out the schemas
        /// and all objects in the database connection.
        /// </summary>
        /// <param name="server">The server to fill catalogs only.</param>
        /// <param name="connection">The open database connection to use.</param>
        /// <param name="metadataScriptFactory">The script factory determined by the database type.</param>
        /// <param name="cancellationToken">The optional cancellation token.</param>
        public static async Task BuildAsync(
            Server server, DbConnection connection,
            IMetadataScriptFactory metadataScriptFactory,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.ThrowIfCancellationRequested();
            await GetAsync(server, connection, metadataScriptFactory, cancellationToken);

            foreach (var catalog in server.Catalogs)
            {
                await SchemaAdapter.BuildAsync(catalog, connection, metadataScriptFactory, cancellationToken);
            }
        }
示例#9
0
        public static void Build(
            Catalog catalog,
            DbConnection connection,
            IMetadataScriptFactory metadataScriptFactory)
        {
            Get(catalog, connection, metadataScriptFactory);
            if (catalog.Schemas.Count == 0)
            {
                return;
            }

            UserDefinedDataTypeAdapter.Get(catalog, connection, metadataScriptFactory);
            UserTableAdapter.Build(catalog, connection, metadataScriptFactory);
            ModuleAdapter.Get(catalog, connection, metadataScriptFactory);
        }
示例#10
0
        public static async Task BuildAsync(
            Catalog catalog,
            DbConnection connection,
            IMetadataScriptFactory metadataScriptFactory,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.ThrowIfCancellationRequested();
            await GetAsync(catalog, connection, metadataScriptFactory, cancellationToken);

            if (catalog.Schemas.Count == 0)
            {
                return;
            }

            await UserDefinedDataTypeAdapter.GetAsync(catalog, connection, metadataScriptFactory, cancellationToken);

            await UserTableAdapter.BuildAsync(catalog, connection, metadataScriptFactory, cancellationToken);

            await ModuleAdapter.GetAsync(catalog, connection, metadataScriptFactory, cancellationToken);
        }
        public static void Get(
            Catalog catalog,
            DbConnection connection,
            IMetadataScriptFactory metadataScriptFactory)
        {
            using (var command = connection.CreateCommand())
            {
                command.CommandText = metadataScriptFactory.UserDefinedDataTypes(catalog.ObjectName);
                using (var reader = command.ExecuteReader())
                {
                    if (!reader.HasRows)
                    {
                        reader.Close();
                        return;
                    }

                    Read(catalog, reader);

                    reader.Close();
                }
            }
        }
示例#12
0
        /// <summary>
        /// Fills only the catalogs in the server object.
        /// </summary>
        /// <param name="server">The server to fill catalogs only.</param>
        /// <param name="connection">The open database connection to use.</param>
        /// <param name="metadataScriptFactory">The metadata script factory determined by the database type.</param>
        public static void Get(
            Server server,
            DbConnection connection,
            IMetadataScriptFactory metadataScriptFactory)
        {
            using (var command = connection.CreateCommand())
            {
                command.CommandText = metadataScriptFactory.Catalogs();
                using (var reader = command.ExecuteReader())
                {
                    if (!reader.HasRows)
                    {
                        reader.Close();
                        return;
                    }

                    Read(server, reader);

                    reader.Close();
                }
            }
        }
示例#13
0
        public static void Get(
            Catalog catalog,
            Dictionary <string, UserTable> userTables,
            DbConnection connection,
            IMetadataScriptFactory metadataScriptFactory)
        {
            using (var command = connection.CreateCommand())
            {
                command.CommandText = metadataScriptFactory.Indexes(catalog.ObjectName);
                using (var reader = command.ExecuteReader())
                {
                    if (!reader.HasRows)
                    {
                        reader.Close();
                        return;
                    }

                    Read(userTables, reader);

                    reader.Close();
                }
            }
        }
示例#14
0
        public static void Build(
            Catalog catalog,
            DbConnection connection,
            IMetadataScriptFactory metadataScriptFactory)
        {
            var userTables = Get(catalog, connection, metadataScriptFactory);

            if (userTables.Count == 0)
            {
                return;
            }

            UserTableColumnAdapter.Get(catalog, userTables, connection, metadataScriptFactory);
            var primaryKeyColumns       = PrimaryKeyAdapter.Get(catalog, userTables, connection, metadataScriptFactory);
            var uniqueConstraintColumns = UniqueConstraintAdapter.Get(catalog, userTables, connection, metadataScriptFactory);

            ForeignKeyAdapter.Get(catalog, userTables, primaryKeyColumns, uniqueConstraintColumns, connection, metadataScriptFactory);
            ComputedColumnsAdapter.Get(catalog, userTables, connection, metadataScriptFactory);
            DefaultConstraintAdapter.Get(catalog, userTables, connection, metadataScriptFactory);
            CheckConstraintAdapter.Get(catalog, userTables, connection, metadataScriptFactory);
            IdentityColumnAdapter.Get(catalog, userTables, connection, metadataScriptFactory);
            IndexAdapter.Get(catalog, userTables, connection, metadataScriptFactory);
        }
示例#15
0
        /// <summary>
        /// Fills only the catalogs in the server object.
        /// </summary>
        /// <param name="server">The server to fill catalogs only.</param>
        /// <param name="connection">The open database connection to use.</param>
        /// <param name="metadataScriptFactory">The metadata script factory determined by the database type.</param>
        /// <param name="cancellationToken">The optional cancellation token.</param>
        public static async Task GetAsync(
            Server server, DbConnection connection,
            IMetadataScriptFactory metadataScriptFactory,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            cancellationToken.ThrowIfCancellationRequested();
            using (var command = connection.CreateCommand())
            {
                command.CommandText = metadataScriptFactory.Catalogs();
                using (var reader = await command.ExecuteReaderAsync(cancellationToken))
                {
                    if (!reader.HasRows)
                    {
                        reader.Close();
                        return;
                    }

                    await ReadAsync(server, reader, cancellationToken);

                    reader.Close();
                }
            }
        }