コード例 #1
0
        public DatabaseCSharpDiagramGenerator
            (ConnectionSettings connectionSettings)
        {
            this.connSettings = connectionSettings;

            metadataReader       = new DatabaseReader(connSettings.ConnectionString, connSettings.ServerType);
            metadataReader.Owner = connSettings.Schema;

            tables = metadataReader.AllTables();
            views  = metadataReader.AllViews();
        }
コード例 #2
0
        public List <AuthorizationDatabaseTable> LoadViews()
        {
            if (_views != null)
            {
                return(_views);
            }

            using (var connection = _databaseConnectionProvider.CreateConnection(_connectionString))
            {
                connection.Open();

                using (var dr = new DatabaseReader(connection))
                {
                    dr.CommandTimeout = 60;

                    _views = dr.AllViews().Select(
                        v => new AuthorizationDatabaseTable()
                    {
                        SchemaOwner = v.SchemaOwner,
                        Name        = v.Name,
                        Columns     = v.Columns.Select(x => new AuthorizationDatabaseColumn()
                        {
                            DbDataType   = x.DbDataType,
                            IsPrimaryKey = x.IsPrimaryKey,
                            Length       = x.Length,
                            Name         = x.Name,
                            Nullable     = x.Nullable,
                            Precision    = x.Precision,
                            Scale        = x.Scale
                        })
                    }).ToList();

                    var dataTupleTable = dr.Table("EducationOrganizationIdToEducationOrganizationId");

                    _views.Add(new AuthorizationDatabaseTable()
                    {
                        SchemaOwner = dataTupleTable.SchemaOwner,
                        Name        = dataTupleTable.Name,
                        Columns     = dataTupleTable.Columns.Select(x => new AuthorizationDatabaseColumn()
                        {
                            DbDataType   = x.DbDataType,
                            IsPrimaryKey = x.IsPrimaryKey,
                            Length       = x.Length,
                            Name         = x.Name,
                            Nullable     = x.Nullable,
                            Precision    = x.Precision,
                            Scale        = x.Scale
                        })
                    });
                }

                return(_views);
            }
        }
コード例 #3
0
        public List <DatabaseView> LoadViews()
        {
            if (_views != null)
            {
                return(_views);
            }

            using (var connection = _databaseConnectionProvider.CreateConnection(_connectionString))
            {
                connection.Open();

                using (var dr = new DatabaseReader(connection))
                {
                    dr.CommandTimeout = 60;
                    _views            = dr.AllViews().ToList();
                }
            }

            return(_views);
        }
コード例 #4
0
ファイル: AdoSource.cs プロジェクト: laredoza/.NetScaffolder
        /// <summary>
        /// The import.
        /// </summary>
        /// <param name="options">
        /// The options.
        /// </param>
        /// <returns>
        /// The <see cref="DatabaseModel"/>.
        /// </returns>
        public DatabaseModel Import(object options)
        {
            Logger.Trace("Started Import()");
            DatabaseModel result = new DatabaseModel();

            AdoSourceOptions adoOptions = options as AdoSourceOptions;

            if (adoOptions == null)
            {
                return(result);
            }

            //foreach (var schemaOwner in adoOptions.Schemas)
            {
                var databaseReader = new DatabaseReader(adoOptions.ConnectionString, adoOptions.ProviderName);

                databaseReader.Exclusions.TableFilter.FilterExclusions.Add("sysdiagrams");
                databaseReader.Exclusions.TableFilter.FilterExclusions.Add("__migrationhistory");
                databaseReader.Exclusions.TableFilter.FilterExclusions.Add("__MigrationHistory");
                databaseReader.Exclusions.TableFilter.FilterExclusions.Add("sys_config");

                databaseReader.AllTables();
                databaseReader.AllViews();



                // databaseReader.AllStoredProcedures(); //but not this one!
                // var schemaMetaData = databaseReader.ReadAll();
                var schemaMetaData = databaseReader.DatabaseSchema;

                List <DatabaseTable> tables = schemaMetaData.Tables
                                              //.Where(t => t.Name != "sysdiagrams" && t.Name != "__migrationhistory" && t.Name != "__MigrationHistory")
                                              .ToList();

                foreach (var table in tables)
                {
                    if (adoOptions.Schemas.Any(s => s == table.SchemaOwner))
                    {
                        DatabaseSchemaFixer.UpdateReferences(schemaMetaData);

                        var newTable = new Table {
                            TableName = table.Name, SchemaName = table.SchemaOwner
                        };
                        result.Tables.Add(newTable);

                        this.AddColumns(table, newTable);

                        this.AddforeignKeys(table, schemaMetaData, newTable);

                        this.AddforeignKeyChildren(table, schemaMetaData, newTable);

                        FormatNavigationPropertiesToBeUnique(newTable);

                        AddIndexes(table, newTable);
                    }
                }
            }

            this.Fix(result);
            Logger.Trace("Completed Import()");
            return(result);
        }