fix(configuration-database): resolve ConfigurationDatabase-001 — remove dead child-template query in GetTemplateWithChildrenAsync
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user