diff --git a/csharp/App/Backend/Controller.cs b/csharp/App/Backend/Controller.cs index 6c4f5bee3..4d23b77ef 100644 --- a/csharp/App/Backend/Controller.cs +++ b/csharp/App/Backend/Controller.cs @@ -2534,9 +2534,26 @@ public class Controller : ControllerBase if (user is null || user.UserType != 2) return Unauthorized(); var tickets = Db.GetAllTickets(); + + var installationIds = tickets + .Where(t => t.InstallationId.HasValue) + .Select(t => t.InstallationId!.Value) + .Distinct() + .ToList(); + + var installationsById = installationIds.Count == 0 + ? new Dictionary() + : Db.Installations + .Where(i => installationIds.Contains(i.Id)) + .ToList() + .ToDictionary(i => i.Id); + var summaries = tickets.Select(t => { - var installation = t.InstallationId.HasValue ? Db.GetInstallationById(t.InstallationId.Value) : null; + Installation? installation = null; + if (t.InstallationId.HasValue) + installationsById.TryGetValue(t.InstallationId.Value, out installation); + return new { t.Id, t.Subject, t.Status, t.Priority, t.Category, t.SubCategory,