protected Constraint(ObjectName name, Table table, ConstraintType constraintType, IEnumerable<Column> keyColumns) { _name = name; _table = table; _constraintType = constraintType; _keyColumns = new List<Column>(keyColumns); }
public override void BeginTableVisit(Table table) { foreach (Rule rule in _rules) { _report.SetCurrentRule(rule); rule.CheckTable(_report, table); } }
internal ForeignKeyConstraint(ObjectName name, Table table, ConstraintType constraintType, IEnumerable<Column> keyColumns, TableConstraint uniqueConstraint, ForeignKeyRule updateRule, ForeignKeyRule deleteRule, bool? isDisabled) : base(name, table, constraintType, keyColumns) { _uniqueConstraint = uniqueConstraint; _updateRule = updateRule; _deleteRule = deleteRule; _isDisabled = isDisabled; }
public Column(Table table, string name, int ordinalPosition, string columnDefault, bool isNullable, string dataType, int? characterMaximumLength, int? characterOctetLength, int? numericPrecision, int? numericPrecisionRadix, int? numericScale, int? datetimePrecision, string collationName) { _table = table; _name = name; _parsedName = new ParsedIdentifier(name); _ordinalPosition = ordinalPosition; _columnDefault = columnDefault; _isNullable = isNullable; _dataType = dataType; _characterMaximumLength = characterMaximumLength; _characterOctetLength = characterOctetLength; _numericPrecision = numericPrecision; _numericPrecisionRadix = numericPrecisionRadix; _numericScale = numericScale; _datetimePrecision = datetimePrecision; _collationName = collationName; }
internal static IEnumerable<Column> ResolveColumns(IEnumerable<string> columnNames, Table table) { List<Column> columns = new List<Column>(); foreach (string columnName in columnNames) { if (!table.Columns.ContainsKey(columnName)) { throw new InvalidOperationException("A column referenced in a constraint does not exist in the table."); } columns.Add(table.Columns[columnName]); } return columns; }
static IEnumerable<Table> EdgeGetter(Table table) { foreach (ForeignKeyConstraint constraint in table.ForeignKeyConstraints) { if (constraint.IsDisabled ?? false) continue; yield return constraint.UniqueConstraint.Table; } }
public static void CreateFilteredDependenciesGraph(Database database, Table startTable, Plan plan) { Set<Table> visited = new Set<Table>(); Stack<Table> seen = new Stack<Table>(); seen.Push(startTable); // The relations that, as a precondition of the delete, must not exist: while (seen.Count > 0) { Table table = seen.Pop(); visited.UnionUpdate(table); foreach (ForeignKeyConstraint constraint in table.ForeignKeyDependencies) { if (plan.IsConstraintExcludedFromDependencyDiagram(constraint)) continue; if (!visited.Contains(constraint.Table)) { seen.Push(constraint.Table); } } } CreateDependenciesGraph(database, visited); }
internal TableConstraint(ObjectName name, Table table, ConstraintType constraintType, IEnumerable<Column> keyColumns) : base(name, table, constraintType, keyColumns) { _relatedForeignKeyConstraints = new Dictionary<ObjectName, ForeignKeyConstraint>(); }
public override void BeginTableVisit(Table table) { Console.WriteLine(string.Format(" Table {0}.{1}", table.Name.Schema, table.Name.Name)); }
public static Database FromConnection(SqlConnection connection) { Database database = null; Dictionary<ObjectName, Table> tables = new Dictionary<ObjectName, Table>(); using (SqlCommand command = new SqlCommand()) { command.Connection = connection; command.CommandText = "SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE FROM INFORMATION_SCHEMA.TABLES"; using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { // Create the database upon reading the first row so that the database name // can be set using the canonical capitalisation. if (database == null) database = new Database(reader.GetString(0)); Table table = new Table(database, new ObjectName(reader.GetString(1), reader.GetString(2))); tables[table.Name] = table; } } } foreach (Table table in tables.Values) { table.LoadColumnsFromDatabase(connection); } database._tables = tables; database._tablesByShortName = new Dictionary<string, Table>(); foreach (Table table in tables.Values) { database._tablesByShortName[table.ParsedName.Value] = table; } Constraint.PopulateTableConstraintsFromConnection(connection, database); return database; }
public virtual void EndTableVisit(Table table) { }
public virtual void BeginTableVisit(Table table) { }
public virtual void CheckTable(ViolationReport report, Table table) { }