using MediatR; using ReC.Application.Common.Dto; using ReC.Application.Common.Interfaces; using Microsoft.EntityFrameworkCore; namespace ReC.Application.Common.Behaviors.Action; public class BodyQueryBehavior(IRecDbContext dbContext) : IPipelineBehavior where TRequest : RecActionViewDto where TResponse : notnull { public async Task Handle(TRequest action, RequestHandlerDelegate next, CancellationToken cancel) { if (action.BodyQuery is null) return await next(cancel); var result = await dbContext.BodyQueryResults.FromSqlRaw(action.BodyQuery).SingleOrDefaultAsync(cancel); action.Body = result?.RawBody; return await next(cancel); } }