Writing queries
We will now create our first query, which is a request for reading data, and a query handler, which will resolve what the query needs. Again, the controller is responsible for sending or dispatching the queries to the relevant handlers.
The following is a block of code for ExportToursQuery
and its handler. You will see later how the controller will use ExportToursQuery
as an argument in the mediator's Send
method:
// ExportToursQuery.cs
using AutoMapper; using AutoMapper.QueryableExtensions; using MediatR; … namespace Travel.Application.TourLists.Queries.ExportTours {   public class ExportToursQuery : IRequest<ExportToursVm>   {     public int ListId { get; set; }   }   public class ExportToursQueryHandler :     IRequestHandler<ExportToursQuery, ExportToursVm>   {     …     public async Task<ExportToursVm...