From 1c770250cefecbd1800fd52b8a120a7662019af0 Mon Sep 17 00:00:00 2001 From: Stuart Ferguson Date: Thu, 12 Feb 2026 08:38:25 +0000 Subject: [PATCH] Handle empty query results with non-null response Previously, the method could return a null or uninitialized response when no query results were found. Now, it always returns a valid TransactionDetailReportResponse with empty Summary and Transactions, ensuring consistent and non-null responses. --- EstateReportingAPI.BusinessLogic/ReportingManager.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/EstateReportingAPI.BusinessLogic/ReportingManager.cs b/EstateReportingAPI.BusinessLogic/ReportingManager.cs index abeff19..5e723a7 100644 --- a/EstateReportingAPI.BusinessLogic/ReportingManager.cs +++ b/EstateReportingAPI.BusinessLogic/ReportingManager.cs @@ -651,7 +651,11 @@ from s in sJoin.DefaultIfEmpty() // Ok now enumerate the results var queryResults = await query.ToListAsync(cancellationToken); if (queryResults.Any() == false) - return response; + return new TransactionDetailReportResponse + { + Summary = new TransactionDetailSummary(), + Transactions = new List() + }; // Now to translate the results response = new TransactionDetailReportResponse {