Optimize ShippingDocuments query order

Reordered LINQ method calls to filter ShippingDocuments by foreign keys before loading related PartnerDepot entities. This change ensures only relevant related data is loaded, improving query performance without altering logic.
This commit is contained in:
Loretta 2026-07-10 17:47:48 +02:00
parent 4081bddfcc
commit 1236fb523d
1 changed files with 2 additions and 2 deletions

View File

@ -390,8 +390,8 @@ namespace Nop.Plugin.Misc.FruitBankPlugin.Controllers
// Bejövő: a csoport ÖSSZES szállítólevele EGY tradeCard-dá (összevont tömeg/érték); GetAll(true) = teljes gráf.
// A PartnerDepot szándékosan NINCS a default loadRelations-ben — csak itt kell (felrakodási hely = depot címe).
var documents = await ctx.ShippingDocuments.GetAll(true)
.LoadWith(sd => sd.PartnerDepot)
.Where(sd => foreignKeys.Contains(sd.Id)).ToListAsync();
.Where(sd => foreignKeys.Contains(sd.Id))
.LoadWith(sd => sd.PartnerDepot).ToListAsync();
if (documents.Count == 0) throw new InvalidOperationException($"EkaerHistory #{ekaerHistoryId}: no ShippingDocuments found for the mapped ids.");
ekaerHistory = fruitBankEkaerService.GenerateEkaerXmlDocument(documents, ekaerHistory);