- Updated `ISQLExecutor<TEntity>` to inherit from new `ISQLExecutor` interface for improved SQL execution flexibility. - Added package references for `Dapper` and `DigitalData.Core` in project files. - Modified `CreateEnvelopeCommand` to include `[BindNever]` on `UserId` for better model binding control. - Refactored `CreateEnvelopeCommandHandler` to use `DynamicParameters` for SQL parameter handling. - Updated `CreateEnvelopeSQL` to select only the top record for performance. - Introduced `GetIdOrDefault` method in `ControllerExtensions` for user ID retrieval with fallback. - Added `CreateAsync` method in `EnvelopeController` for envelope creation using `IMediator`. - Ensured infrastructure project has necessary package references. - Refactored `SQLExecutor` to implement new interface and simplified constructor. - Introduced `SQLExecutorBaseEntity` for entity-specific SQL command execution.
28 lines
1.9 KiB
C#
28 lines
1.9 KiB
C#
namespace EnvelopeGenerator.Application.Contracts.SQLExecutor;
|
|
|
|
/// <summary>
|
|
/// Defines methods for executing raw SQL queries or custom SQL query classes and returning query executors for further operations.
|
|
/// Provides abstraction for raw SQL execution as well as mapping the results to <typeparamref name="TEntity"/> objects.
|
|
/// </summary>
|
|
/// <typeparam name="TEntity">The entity type to which the SQL query results will be mapped.</typeparam>
|
|
public interface ISQLExecutor<TEntity>: ISQLExecutor
|
|
{
|
|
/// <summary>
|
|
/// Executes a raw SQL query and returns an <see cref="IQuery{TEntity}"/> for further querying operations on the result.
|
|
/// </summary>
|
|
/// <param name="sql">The raw SQL query to execute.</param>
|
|
/// <param name="cancellation">Optional cancellation token for the operation.</param>
|
|
/// <param name="parameters">Optional parameters for the SQL query.</param>
|
|
/// <returns>An <see cref="IQuery{TEntity}"/> instance for further query operations on the result.</returns>
|
|
IQuery<TEntity> Execute(string sql, CancellationToken cancellation = default, params object[] parameters);
|
|
|
|
/// <summary>
|
|
/// Executes a custom SQL query defined by a class that implements <see cref="ISQL{TEntity}"/> and returns an <see cref="IQuery{TEntity}"/> for further querying operations on the result.
|
|
/// </summary>
|
|
/// <typeparam name="TSQL">The type of the custom SQL query class implementing <see cref="ISQL{TEntity}"/>.</typeparam>
|
|
/// <param name="cancellation">Optional cancellation token for the operation.</param>
|
|
/// <param name="parameters">Optional parameters for the SQL query.</param>
|
|
/// <returns>An <see cref="IQuery{TEntity}"/> instance for further query operations on the result.</returns>
|
|
IQuery<TEntity> Execute<TSQL>(CancellationToken cancellation = default, params object[] parameters) where TSQL : ISQL<TEntity>;
|
|
}
|