diff --git a/src/ZB.MOM.WW.ScadaBridge.Commons/Interfaces/Repositories/ITemplateEngineRepository.cs b/src/ZB.MOM.WW.ScadaBridge.Commons/Interfaces/Repositories/ITemplateEngineRepository.cs index 091f5396..c78677e6 100644 --- a/src/ZB.MOM.WW.ScadaBridge.Commons/Interfaces/Repositories/ITemplateEngineRepository.cs +++ b/src/ZB.MOM.WW.ScadaBridge.Commons/Interfaces/Repositories/ITemplateEngineRepository.cs @@ -31,6 +31,16 @@ public interface ITemplateEngineRepository /// Cancellation token. /// A task that resolves to a read-only list of matched templates with children loaded. Task> GetTemplatesWithChildrenAsync(IEnumerable names, CancellationToken cancellationToken = default); + /// + /// restricted to + /// BASE templates ( is false). Derived templates carry their + /// composition slot name, so a by-name read meant for the user-authored template the name + /// identifies (a bundle import's target) would otherwise also match derived rows (ScadaBridge#95). + /// + /// Template names to load. Duplicate / null / empty names are filtered out. + /// Cancellation token. + /// A task that resolves to the matched base templates with children loaded. + Task> GetBaseTemplatesWithChildrenAsync(IEnumerable names, CancellationToken cancellationToken = default); /// Retrieves all templates. /// Cancellation token. /// A task that resolves to a read-only list of all templates. diff --git a/src/ZB.MOM.WW.ScadaBridge.ConfigurationDatabase/Repositories/TemplateEngineRepository.cs b/src/ZB.MOM.WW.ScadaBridge.ConfigurationDatabase/Repositories/TemplateEngineRepository.cs index ba088f47..5bef7c5a 100644 --- a/src/ZB.MOM.WW.ScadaBridge.ConfigurationDatabase/Repositories/TemplateEngineRepository.cs +++ b/src/ZB.MOM.WW.ScadaBridge.ConfigurationDatabase/Repositories/TemplateEngineRepository.cs @@ -53,8 +53,17 @@ public class TemplateEngineRepository : ITemplateEngineRepository } /// - public async Task> GetTemplatesWithChildrenAsync( + public Task> GetTemplatesWithChildrenAsync( IEnumerable names, CancellationToken cancellationToken = default) + => GetTemplatesWithChildrenAsync(names, baseOnly: false, cancellationToken); + + /// + public Task> GetBaseTemplatesWithChildrenAsync( + IEnumerable names, CancellationToken cancellationToken = default) + => GetTemplatesWithChildrenAsync(names, baseOnly: true, cancellationToken); + + private async Task> GetTemplatesWithChildrenAsync( + IEnumerable names, bool baseOnly, CancellationToken cancellationToken) { // Bulk lookup replaces the per-name N+1 in // BundleImporter.PreviewAsync. Filter out null / empty / duplicate @@ -67,7 +76,7 @@ public class TemplateEngineRepository : ITemplateEngineRepository if (distinct.Length == 0) return Array.Empty