From d00c459124de1eee38a17389ed97d8239ea2e8eb Mon Sep 17 00:00:00 2001 From: TekH Date: Mon, 28 Sep 2026 11:57:41 +0200 Subject: [PATCH] Optimize query with eager loading for related entities Added `Include` statements to the LINQ query in the `ReadEnvelopeQueryHandler` class to eagerly load related entities (`Type`, `EnvelopeReceivers` with `Receiver`, and `Histories`). This change reduces lazy-loading overhead and ensures all necessary data is retrieved in a single query, improving performance. --- .../Envelopes/Queries/ReadEnvelopeQuery.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/EnvelopeGenerator.Application/Envelopes/Queries/ReadEnvelopeQuery.cs b/EnvelopeGenerator.Application/Envelopes/Queries/ReadEnvelopeQuery.cs index a814a3e0..f868e74a 100644 --- a/EnvelopeGenerator.Application/Envelopes/Queries/ReadEnvelopeQuery.cs +++ b/EnvelopeGenerator.Application/Envelopes/Queries/ReadEnvelopeQuery.cs @@ -149,6 +149,7 @@ public class ReadEnvelopeQueryHandler : IRequestHandler Status.Completed.Contains(e.Status)); var envelopes = await query + .Include(e => e.Type) .Include(e => e.EnvelopeReceivers).ThenInclude(er => er.Receiver) .Include(e => e.Histories) .ToListAsync(cancel);