public async Task UpdateAgesByPersonAsync( Person person, CancellationToken cancellationToken) { if (person.DateOfBirth == null) { return; } IEnumerable <MediaFace> faces = await _mediaStore.Faces.GetFacesByPersonAsync( person.Id, cancellationToken); IEnumerable <MediaHeaderData>?medias = await _mediaStore.GetHeaderDataAsync( faces.Select(x => x.MediaId), cancellationToken); ILookup <Guid, MediaHeaderData>?mediaLookup = medias.ToLookup(x => x.Id); List <UpdateAgeRequest> updates = new(); foreach (MediaFace?face in faces) { MediaHeaderData?media = mediaLookup[face.MediaId].Single(); var age = CalculateAge(media.DateTaken, person.DateOfBirth.Value); updates.Add(new UpdateAgeRequest(face.Id, age)); } await _mediaStore.Faces.BulkUpdateAgesAsync(updates, cancellationToken); }