Skip to content

Commit 424def4

Browse files
authored
Update CollectionGraphNode.cs
1 parent b0d6bfe commit 424def4

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

GraphDiff/GraphDiff/Internal/Graph/CollectionGraphNode.cs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,29 @@ public override void Update<T>(DbContext context, T existing, T entity)
4646
}
4747
}
4848

49-
// remove obsolete items
50-
foreach (var dbItem in dbHash.Values)
49+
if (CheckAllowDelete(this))
5150
{
52-
RemoveElement(context, dbItem, dbCollection);
51+
// remove obsolete items
52+
foreach (var dbItem in dbHash.Values)
53+
{
54+
RemoveElement(context, dbItem, dbCollection);
55+
}
56+
}
57+
}
58+
59+
private static bool CheckAllowDelete(GraphNode node)
60+
{
61+
if (node.AllowDelete != null)
62+
{
63+
return (bool)node.AllowDelete;
64+
}
65+
else if (node.Parent != null)
66+
{
67+
return CheckAllowDelete(node.Parent);
68+
}
69+
else
70+
{
71+
return true;
5372
}
5473
}
5574

0 commit comments

Comments
 (0)