refactor(application): consolidate query architecture with AutoMapper integration

- Add AutoMapper profile for CfgProfile and ProfileSqlJob entity-to-DTO mappings
- Consolidate GetProfileByIdQuery and GetAllActiveProfilesQuery into unified GetProfileQuery
- Implement flexible filtering with nullable query options (Id, Active, TypeId, ProfileName)
- Add IncludeSqlJobs option for optimized SQL job loading
- Move CfgProfileDto to Common/Dtos for better architecture alignment
- Add comprehensive unit tests for GetProfileQuery with multiple filter scenarios
- Move ISQLExecutor interface from Domain to Application layer
- Add GetByIdWithSqlJobsAsync and GetAllActiveWithSqlJobsAsync to repository
This commit is contained in:
2026-07-11 19:14:51 +02:00
parent 3f924b75b0
commit eaf24e05ee
15 changed files with 629 additions and 16 deletions

View File

@@ -1,4 +1,7 @@
using ECMJobRunner.Domain.Entities;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace ECMJobRunner.Domain.Interfaces
{
@@ -7,6 +10,19 @@ namespace ECMJobRunner.Domain.Interfaces
/// </summary>
public interface ICfgProfileRepository : IRepository<CfgProfile>
{
// Add custom CfgProfile-specific methods here if needed
/// <summary>
/// Gets a profile by ID with associated SQL jobs eagerly loaded
/// </summary>
/// <param name="id">Profile ID</param>
/// <param name="cancellationToken">Cancellation token</param>
/// <returns>Profile with SQL jobs or null if not found</returns>
Task<CfgProfile?> GetByIdWithSqlJobsAsync(long id, CancellationToken cancellationToken = default);
/// <summary>
/// Gets all active profiles with associated SQL jobs eagerly loaded
/// </summary>
/// <param name="cancellationToken">Cancellation token</param>
/// <returns>List of active profiles with SQL jobs</returns>
Task<List<CfgProfile>> GetAllActiveWithSqlJobsAsync(CancellationToken cancellationToken = default);
}
}

View File

@@ -1,20 +0,0 @@
using System.Threading;
using System.Threading.Tasks;
namespace ECMJobRunner.Domain.Interfaces
{
/// <summary>
/// Interface for executing SQL queries and mapping results to DTOs
/// </summary>
public interface ISQLExecutor
{
/// <summary>
/// Executes a SQL query and maps the result to the specified type
/// </summary>
/// <typeparam name="TResult">The type to map the query result to</typeparam>
/// <param name="sql">The SQL query to execute</param>
/// <param name="cancellationToken">Cancellation token</param>
/// <returns>The mapped result or null if no result</returns>
Task<TResult?> ExecuteQueryAsync<TResult>(string sql, CancellationToken cancellationToken = default);
}
}