private void DoGenerateCascadeDeletions(DatabaseInfo db, List <ChangeSetDeleteItem> res) { var table = db.FindTable(TargetTable); if (table == null) { return; } foreach (var fk in table.GetReferences()) { if (res.Any(x => x.TargetTable == fk.OwnerTable.FullName)) { // prevent cycling continue; } if (fk.OwnerTable == fk.RefTable) { // skip foreign keys referencing the same table continue; } var newItem = new ChangeSetDeleteItem { LinkedInfo = LinkedInfo, TargetTable = fk.OwnerTable.FullName, }; newItem.Conditions.AddRange(GetPrefixedConditions(Conditions, fk.ConstraintName)); res.Add(newItem); newItem.DoGenerateCascadeDeletions(db, res); } }
private void DoGenerateCascadeDeletions(DatabaseInfo db, List<ChangeSetDeleteItem> res) { var table = db.FindTable(TargetTable); if (table == null) return; foreach (var fk in table.GetReferences()) { if (res.Any(x => x.TargetTable == fk.OwnerTable.FullName)) { // prevent cycling continue; } var newItem = new ChangeSetDeleteItem { LinkedInfo = LinkedInfo, TargetTable = fk.OwnerTable.FullName, }; newItem.Conditions.AddRange(GetPrefixedConditions(Conditions, fk.ConstraintName)); res.Add(newItem); newItem.DoGenerateCascadeDeletions(db, res); } }