fix(configuration-database): resolve ConfigurationDatabase-001 — remove dead child-template query in GetTemplateWithChildrenAsync

This commit is contained in:
Joseph Doherty
2026-05-16 19:33:09 -04:00
parent 301e7fb854
commit 9043f0089b
3 changed files with 121 additions and 12 deletions

View File

@@ -27,17 +27,15 @@ public class TemplateEngineRepository : ITemplateEngineRepository
.FirstOrDefaultAsync(t => t.Id == id, cancellationToken);
}
/// <summary>
/// Loads a template together with its child members — Attributes, Alarms,
/// Scripts and Compositions — eager-loaded so callers get the full template
/// aggregate in a single round-trip. "Children" here refers to the template's
/// member collections, not derived/sub templates.
/// </summary>
public async Task<Template?> GetTemplateWithChildrenAsync(int id, CancellationToken cancellationToken = default)
{
var template = await GetTemplateByIdAsync(id, cancellationToken);
if (template == null) return null;
// Load all templates that have this template as parent
var children = await _context.Templates
.Where(t => t.ParentTemplateId == id)
.ToListAsync(cancellationToken);
return template;
return await GetTemplateByIdAsync(id, cancellationToken);
}
public async Task<IReadOnlyList<Template>> GetAllTemplatesAsync(CancellationToken cancellationToken = default)