This commit is contained in:
parent
13a8e309e7
commit
cba16f25b9
1 changed files with 8 additions and 4 deletions
|
|
@ -572,12 +572,16 @@ public class ImportBackgroundService : BackgroundService
|
||||||
|
|
||||||
var rec_import_id = rec_import.Id;
|
var rec_import_id = rec_import.Id;
|
||||||
var rec_import_year = rec_import.Year;
|
var rec_import_year = rec_import.Year;
|
||||||
var hasExistingScores = rec_import.ScoreImport != null && rec_import.ScoreImport.Scores != null;
|
var existingScoreImport = rec_import.ScoreImport;
|
||||||
|
|
||||||
if (hasExistingScores)
|
if (existingScoreImport != null)
|
||||||
{
|
{
|
||||||
var existingScores = rec_import.ScoreImport.Scores.ToList();
|
var existingScores = existingScoreImport.Scores?.ToList() ?? new List<RecruitScore>();
|
||||||
|
if (existingScores.Count > 0)
|
||||||
await _context.BulkDeleteAsync(existingScores);
|
await _context.BulkDeleteAsync(existingScores);
|
||||||
|
// Also delete the ScoreImport row itself (has unique index on RecruitImportId)
|
||||||
|
_context.ChangeTracker.Clear();
|
||||||
|
await _context.BulkDeleteAsync(new List<ScoreImport> { existingScoreImport });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear tracker to avoid stale references after BulkDelete (which bypasses EF tracking)
|
// Clear tracker to avoid stale references after BulkDelete (which bypasses EF tracking)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue