Skip to content

Commit f382e4b

Browse files
committed
Wrap multiple INSERT statements within a single transaction
1 parent e3be0ca commit f382e4b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

DevProxy.Abstractions/Data/MSGraphDb.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ private async Task CreateDbAsync(CancellationToken cancellationToken)
110110
private async Task FillDataAsync(CancellationToken cancellationToken)
111111
{
112112
_logger.LogInformation("Filling database...");
113+
114+
await using var transaction = await Connection.BeginTransactionAsync(cancellationToken);
113115

114116
var i = 0;
115117

@@ -154,6 +156,8 @@ private async Task FillDataAsync(CancellationToken cancellationToken)
154156
}
155157
}
156158

159+
await transaction.CommitAsync(cancellationToken);
160+
157161
_logger.LogInformation("Inserted {EndpointCount} endpoints in the database", i);
158162
}
159163

0 commit comments

Comments
 (0)