public DatabaseTable Execute(CancellationToken ct, string tableName) { if (ct.IsCancellationRequested) { return(null); } var tables = _readerAdapter.Tables(tableName); if (tables.Count == 0) { return(null); } if (string.IsNullOrEmpty(_readerAdapter.Parameters.Owner)) { var owner = tables[0].SchemaOwner; Trace.WriteLine("Using first schema " + owner); _readerAdapter.Parameters.Owner = owner; } var columns = _readerAdapter.Columns(tableName); var identityColumns = _readerAdapter.IdentityColumns(tableName); var checkConstraints = _readerAdapter.CheckConstraints(tableName); var pks = _readerAdapter.PrimaryKeys(tableName); var uks = _readerAdapter.UniqueKeys(tableName); var fks = _readerAdapter.ForeignKeys(tableName); var dfs = _readerAdapter.DefaultConstraints(tableName); var triggers = _readerAdapter.Triggers(tableName); var tableDescs = _readerAdapter.TableDescriptions(tableName); var colDescs = _readerAdapter.ColumnDescriptions(tableName); var computed = _readerAdapter.ComputedColumns(tableName); var indexes = MergeIndexColumns(_readerAdapter.Indexes(tableName), _readerAdapter.IndexColumns(tableName)); if (columns.Count == 0) { return(null); } var table = new DatabaseTable { SchemaOwner = _readerAdapter.Parameters.Owner, Name = tableName }; table.Columns.AddRange(columns); UpdateCheckConstraints(table, checkConstraints); UpdateIdentities(table.Columns, identityColumns); UpdateComputed(table.Columns, computed); UpdateConstraints(table, pks, ConstraintType.PrimaryKey); UpdateConstraints(table, uks, ConstraintType.UniqueKey); UpdateConstraints(table, fks, ConstraintType.ForeignKey); UpdateConstraints(table, dfs, ConstraintType.Default); UpdateIndexes(table, indexes); UpdateTriggers(table, triggers); UpdateTableDescriptions(table, tableDescs); UpdateColumnDescriptions(table, colDescs); _readerAdapter.PostProcessing(table); return(table); }
/// <summary> /// Gets all tables with columns and datatypes but nothing else (no constraints, indexes or triggers). /// </summary> public IList <DatabaseTable> TablesQuickView() { RaiseReadingProgress(SchemaObjectType.Tables); IList <DatabaseTable> tables; using (_readerAdapter.CreateConnection()) { tables = _readerAdapter.Tables(null); } DatabaseSchema.Tables.Clear(); DatabaseSchema.Tables.AddRange(tables); RaiseReadingProgress(SchemaObjectType.Columns); IList <DatabaseColumn> columns; using (_readerAdapter.CreateConnection()) { columns = _readerAdapter.Columns(null); } foreach (var table in DatabaseSchema.Tables) { table.Columns.Clear(); table.Columns.AddRange( columns.Where(x => string.Equals(x.TableName, table.Name, StringComparison.OrdinalIgnoreCase) && string.Equals(x.SchemaOwner, table.SchemaOwner, StringComparison.OrdinalIgnoreCase))); } DataTypes(); return(DatabaseSchema.Tables); }