- Move ISQLExecutor interface from Application to Domain layer - Follow Clean Architecture: Infrastructure references Domain, not Application - Namespace: ECMJobRunner.Domain.Interfaces - Implement SQLExecutor service with conditional compilation - EF6 (net480): Database.SqlQuery<T>() - EF Core (net8.0): Database.SqlQueryRaw<T>() - Register ISQLExecutor in DI (AddInfrastructure, AddInfrastructureInMemory) - Scoped lifetime (aligns with DbContext)
21 lines
778 B
C#
21 lines
778 B
C#
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);
|
|
}
|
|
}
|