Optimize bulk insert on conflict options

This commit is contained in:
LittleSheep 2025-05-22 01:55:02 +08:00
parent 288d66221a
commit 95b3ab6bcd
2 changed files with 2 additions and 2 deletions

View File

@ -62,7 +62,7 @@ public class AccountService(
if (missingId.Count != 0) if (missingId.Count != 0)
{ {
var newProfiles = missingId.Select(id => new Profile { AccountId = id }).ToList(); var newProfiles = missingId.Select(id => new Profile { AccountId = id }).ToList();
await db.BulkInsertAsync(newProfiles); await db.BulkInsertAsync(newProfiles, config => config.ConflictOption = ConflictOption.Ignore);
} }
} }
} }

View File

@ -11,7 +11,7 @@ public class ActionLogFlushHandler(IServiceProvider serviceProvider) : IFlushHan
using var scope = serviceProvider.CreateScope(); using var scope = serviceProvider.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<AppDatabase>(); var db = scope.ServiceProvider.GetRequiredService<AppDatabase>();
await db.BulkInsertAsync(items); await db.BulkInsertAsync(items, config => config.ConflictOption = ConflictOption.Ignore);
} }
} }