From ec119a3045cfd0fd91b402418a9823ef1f820f54 Mon Sep 17 00:00:00 2001 From: TekH Date: Mon, 2 Mar 2026 13:57:14 +0100 Subject: [PATCH] Add options to include Action/Profile in ResultView queries Added IncludeAction and IncludeProfile properties to ReadResultViewQuery, allowing callers to control eager loading of related Action and Profile entities. Updated handler to conditionally include these navigation properties based on the new flags for more flexible data retrieval. --- .../Results/Queries/ReadResultViewQuery.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/ReC.Application/Results/Queries/ReadResultViewQuery.cs b/src/ReC.Application/Results/Queries/ReadResultViewQuery.cs index 939e0c1..4a65a4e 100644 --- a/src/ReC.Application/Results/Queries/ReadResultViewQuery.cs +++ b/src/ReC.Application/Results/Queries/ReadResultViewQuery.cs @@ -16,6 +16,10 @@ public record ReadResultViewQuery : IRequest> public long? ActionId { get; init; } = null; public long? ProfileId { get; init; } = null; + + public bool IncludeAction { get; init; } = true; + + public bool IncludeProfile { get; init; } = false; } public class ReadResultViewQueryHandler(IRepository repo, IMapper mapper) : IRequestHandler> @@ -33,6 +37,12 @@ public class ReadResultViewQueryHandler(IRepository repo, IMapper ma if(request.ProfileId is long profileId) q = q.Where(rv => rv.ProfileId == profileId); + if(request.IncludeAction) + q = q.Include(rv => rv.Action); + + if(request.IncludeProfile) + q = q.Include(rv => rv.Profile); + var entities = await q.ToListAsync(cancel); if (entities.Count == 0)