From c8c0ffeb0dc60642bf66732a7d88c022a3e83810 Mon Sep 17 00:00:00 2001 From: Robert McRackan Date: Fri, 15 Apr 2022 16:30:43 -0400 Subject: [PATCH] Bug fix #231 : Some books without categories are not getting imported --- AppScaffolding/AppScaffolding.csproj | 2 +- DtoImporterService/BookImporter.cs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/AppScaffolding/AppScaffolding.csproj b/AppScaffolding/AppScaffolding.csproj index 3910d142..5abc0c54 100644 --- a/AppScaffolding/AppScaffolding.csproj +++ b/AppScaffolding/AppScaffolding.csproj @@ -3,7 +3,7 @@ net6.0 - 6.7.6.2 + 6.7.7.1 diff --git a/DtoImporterService/BookImporter.cs b/DtoImporterService/BookImporter.cs index e4f619ed..406709da 100644 --- a/DtoImporterService/BookImporter.cs +++ b/DtoImporterService/BookImporter.cs @@ -121,7 +121,9 @@ namespace DtoImporterService : item.Categories[1].CategoryId; // This should properly be SingleOrDefault() not FirstOrDefault(), but FirstOrDefault is defensive - var category = DbContext.Categories.Local.FirstOrDefault(c => c.AudibleCategoryId == lastCategory); + var category + = DbContext.Categories.Local.FirstOrDefault(c => c.AudibleCategoryId == lastCategory) + ?? Category.GetEmpty(); Book book; try