diff --git a/SeaHaven.DataServices/Implementation/VendorCompanyRosterDataService.cs b/SeaHaven.DataServices/Implementation/VendorCompanyRosterDataService.cs index cac9637..4b66614 100644 --- a/SeaHaven.DataServices/Implementation/VendorCompanyRosterDataService.cs +++ b/SeaHaven.DataServices/Implementation/VendorCompanyRosterDataService.cs @@ -131,6 +131,7 @@ namespace SeaHaven.DataServices.Implementation var existingTechnicians = await _context.Vendors .Where(v => v.CompanyId == company.Id && (v.IsDeleted == null || v.IsDeleted == false)) .ToListAsync(cancellationToken); + var existingTechniciansById = existingTechnicians.ToDictionary(v => v.Id); var snapshotIds = roster.Technicians .Where(t => t.Id.HasValue) @@ -169,8 +170,7 @@ namespace SeaHaven.DataServices.Implementation { if (technician.Id.HasValue) { - var existing = existingTechnicians.FirstOrDefault(e => e.Id == technician.Id.Value); - if (existing == null) + if (!existingTechniciansById.TryGetValue(technician.Id.Value, out var existing)) continue; existing.ContactName = technician.ContactName;