diff --git a/src/ParcelRegistry.Projections.Extract/ParcelLinkExtract/ParcelLinkExtractProjections.cs b/src/ParcelRegistry.Projections.Extract/ParcelLinkExtract/ParcelLinkExtractProjections.cs index 80beea1c..fe066d06 100644 --- a/src/ParcelRegistry.Projections.Extract/ParcelLinkExtract/ParcelLinkExtractProjections.cs +++ b/src/ParcelRegistry.Projections.Extract/ParcelLinkExtract/ParcelLinkExtractProjections.cs @@ -7,6 +7,7 @@ namespace ParcelRegistry.Projections.Extract.ParcelLinkExtract using Be.Vlaanderen.Basisregisters.GrAr.Extracts; using Be.Vlaanderen.Basisregisters.ProjectionHandling.Connector; using Be.Vlaanderen.Basisregisters.ProjectionHandling.SqlStreamStore; + using Microsoft.EntityFrameworkCore; using ParcelRegistry.Parcel.Events; [ConnectedProjectionName("Extract perceelkoppelingen met adres")] @@ -106,7 +107,7 @@ await context .ParcelLinkExtract .FindAsync(new object?[] { message.Message.ParcelId, message.Message.NewAddressPersistentLocalId }, ct); - if (newAddress is null) + if (newAddress is null || context.Entry(newAddress).State == EntityState.Deleted) { await context .ParcelLinkExtract diff --git a/src/ParcelRegistry.Projections.Integration/ParcelLatestItem/ParcelLatestItemProjections.cs b/src/ParcelRegistry.Projections.Integration/ParcelLatestItem/ParcelLatestItemProjections.cs index bc5faccf..4809549f 100644 --- a/src/ParcelRegistry.Projections.Integration/ParcelLatestItem/ParcelLatestItemProjections.cs +++ b/src/ParcelRegistry.Projections.Integration/ParcelLatestItem/ParcelLatestItemProjections.cs @@ -4,6 +4,7 @@ using Be.Vlaanderen.Basisregisters.ProjectionHandling.SqlStreamStore; using Converters; using Infrastructure; + using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Options; using NodaTime; using Parcel; @@ -122,7 +123,7 @@ await context .ParcelLatestItemAddresses .FindAsync([message.Message.ParcelId, message.Message.NewAddressPersistentLocalId], cancellationToken: ct); - if (newAddress is null) + if (newAddress is null || context.Entry(newAddress).State == EntityState.Deleted) { await context .ParcelLatestItemAddresses