How to set return additional parameter for .NET MediatR: Handle (IRequestHandler)

Viewed 163

I am working in .NET 5 application and have implemented MediatR. I have create Abstract class that I am expecting all Handler to implement it. Up to here is all fine but now I need to return record count 'struct' along with MediatR Query Response and unable to do so.. question is how I can set return type of Task<(int, TResponse)> for Handler instead of Task

public abstract class BaseQueryHandler<TRequest, TResponse> : IRequestHandler<TRequest, TResponse>
    where TRequest : IRequest<TResponse> 
{
    protected IAppAmbientState appAmbientState { get; }

    public BaseQueryHandler(IAppAmbientState ambientState)
    {
        this.appAmbientState = ambientState;
    }

    public abstract Task<(int, TResponse)> Handle(TRequest request, CancellationToken cancellationToken);

}
0 Answers
Related