Skip to content

Commit da36d9f

Browse files
Fix changes to row id not persisting
1 parent bde1d52 commit da36d9f

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

WDBXEditor2.Core/Operations/SaveDb2ToFileOperation.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@ public Task Handle(SaveDb2ToFileOperation request, CancellationToken cancellatio
2727
request.ProgressReporter?.SetOperationName("Save DB2 - Writing data...");
2828
request.ProgressReporter?.SetIsIndeterminate(true);
2929

30+
// Fix changed ID fields
31+
var rowsToReadd = dbcdStorage.ToDictionary().Where(pair => pair.Key != pair.Value.ID).ToList();
32+
foreach(var row in rowsToReadd)
33+
{
34+
if (dbcdStorage.ContainsKey(row.Value.ID))
35+
{
36+
throw new InvalidOperationException($"Unable to save DB2 file due to duplicated row ids. Row id: '{row.Value.ID}' exists one more or times.");
37+
}
38+
dbcdStorage.Remove(row.Key);
39+
dbcdStorage.Add(row.Value.ID, row.Value);
40+
}
41+
3042
var tempFile = Path.GetTempFileName();
3143
dbcdStorage.Save(tempFile);
3244

0 commit comments

Comments
 (0)