From 549006775c2f6f3379c7a5b0dc6750a6b88b4ae8 Mon Sep 17 00:00:00 2001 From: plockwood Date: Thu, 23 Nov 2023 12:24:03 +0000 Subject: [PATCH] weird error, first item in the trust search collection did not have trust type, the iclude wasn't working for the first item, resolved by using noTracking, hopefully not an issue in later version of EF --- .../Dfe.Academies.Infrastructure.csproj | 6 +++--- Dfe.Academies.Api.Infrastructure/MstrContext.cs | 2 +- .../Repositories/TrustRepository.cs | 2 +- TramsDataApi/TramsDataApi.csproj | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Dfe.Academies.Api.Infrastructure/Dfe.Academies.Infrastructure.csproj b/Dfe.Academies.Api.Infrastructure/Dfe.Academies.Infrastructure.csproj index c88b78d59..27e0d4c1f 100644 --- a/Dfe.Academies.Api.Infrastructure/Dfe.Academies.Infrastructure.csproj +++ b/Dfe.Academies.Api.Infrastructure/Dfe.Academies.Infrastructure.csproj @@ -9,12 +9,12 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/Dfe.Academies.Api.Infrastructure/MstrContext.cs b/Dfe.Academies.Api.Infrastructure/MstrContext.cs index 0f4bc8aa2..2a6f07e07 100644 --- a/Dfe.Academies.Api.Infrastructure/MstrContext.cs +++ b/Dfe.Academies.Api.Infrastructure/MstrContext.cs @@ -210,7 +210,7 @@ void ConfigureTrust(EntityTypeBuilder trustConfiguration) .HasOne(x => x.TrustType) .WithOne() .HasForeignKey(x => x.TrustsTrustType) - .IsRequired(false); + .IsRequired(true); } void ConfigureTrustType(EntityTypeBuilder trustTypeConfiguration) diff --git a/Dfe.Academies.Api.Infrastructure/Repositories/TrustRepository.cs b/Dfe.Academies.Api.Infrastructure/Repositories/TrustRepository.cs index 8cac36902..f75694fad 100644 --- a/Dfe.Academies.Api.Infrastructure/Repositories/TrustRepository.cs +++ b/Dfe.Academies.Api.Infrastructure/Repositories/TrustRepository.cs @@ -51,7 +51,7 @@ public async Task> GetTrustsByUkprns(string[] ukprns, CancellationTo return (allTrusts, allTrusts.Count); } - IOrderedQueryable filteredGroups = DefaultIncludes() + IOrderedQueryable filteredGroups = DefaultIncludes().AsNoTracking() .Where(trust => (trust.Name.Contains(name) || trust.UKPRN.Contains(ukPrn) || trust.CompaniesHouseNumber.Contains(companiesHouseNumber)) diff --git a/TramsDataApi/TramsDataApi.csproj b/TramsDataApi/TramsDataApi.csproj index ad367d03f..bdbadae54 100644 --- a/TramsDataApi/TramsDataApi.csproj +++ b/TramsDataApi/TramsDataApi.csproj @@ -10,17 +10,17 @@ - + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - +