namespace EnvelopeGenerator.Application.Contracts.SQLExecutor; /// /// Defines methods for executing raw SQL queries and mapping the results to objects. /// /// The entity type to which the SQL query results will be mapped. public interface ISQLExecutor { /// /// Executes a raw SQL query and returns the first result or null if no result is found. /// /// The raw SQL query to execute. /// Optional cancellation token. /// Optional parameters for the SQL query. /// The first result, or null if none found. Task ExecuteFirstAsync(string sql, CancellationToken cancellation = default, params object[] parameters); /// /// Executes a raw SQL query and expects a single result, or null if no result is found. /// /// The raw SQL query to execute. /// Optional cancellation token. /// Optional parameters for the SQL query. /// The single result, or null if none found. Task ExecuteSingleAsync(string sql, CancellationToken cancellation = default, params object[] parameters); /// /// Executes a raw SQL query and returns all results as a collection of . /// /// The raw SQL query to execute. /// Optional cancellation token. /// Optional parameters for the SQL query. /// An containing all matching results. Task> ExecuteAllAsync(string sql, CancellationToken cancellation = default, params object[] parameters); Task ExecuteFirstAsync(CancellationToken cancellation = default, params object[] parameters) where TSQL : ISQL; Task ExecuteSingleAsync(CancellationToken cancellation = default, params object[] parameters) where TSQL : ISQL; Task> ExecuteAllAsync(CancellationToken cancellation = default, params object[] parameters) where TSQL : ISQL; }