Commit 2393e9c
committed
Hack: Delete unmatched topics
While the `Import()` extension method will successfully remove unmatched topics from the topic graph—assuming e.g. `DeleteUnmatchedChildren` is enabled—it doesn't have access to the `ITopicRepository` in order to delete them. The `ITopicRepository` doesn't have a way to detect internal deletions either, however.
In the future, we should evaluate ways of baking this into `ITopicRepository` e.g. by temporarily moving deleted topics to a `Topic.DeletedChildren` collection. For now, however, we can hack around this by taking a snapshot of all topics in the graph before hand, finding the difference afterwards, and deleting those topics that are no longer present.
Technically, this will result in some topics being deleted which are already deleted (e.g., because their parent was already deleted), but, for better or for worse, the `ITopicRepository` handles that situation gracefully (i.e., without throwing an exception).
This is an ugly hack, and especially because it's not intuitive behavior when using the Data Transfer library. It doesn't require too much code, however, and works reliably, so it's an acceptable workaround until a more sophisticated solution can be accounted for in the `ITopicRepository`.1 parent 94b9842 commit 2393e9c
1 file changed
Lines changed: 21 additions & 0 deletions
Lines changed: 21 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| 27 | + | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
| |||
694 | 696 | | |
695 | 697 | | |
696 | 698 | | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
697 | 704 | | |
698 | 705 | | |
699 | 706 | | |
| |||
704 | 711 | | |
705 | 712 | | |
706 | 713 | | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
707 | 728 | | |
708 | 729 | | |
709 | 730 | | |
| |||
0 commit comments