############# Queries usage ############# Once configured, you will need to create the queries that you will send through the mediator. Query creation ============== First, to create a query you have to implement the ``IQuery`` generic interface. For example: .. sourcecode:: csharp public class MyQuery:IQuery { public string QueryData { get; set; } } .. note:: You can use any type that you want for the response. Handler creation ================ Second, you have to create a handler for the above query. For this, you have to implement the ``IQueryHandler`` interface. .. sourcecode:: csharp /// /// Interface for implement a query handler for a concrete query /// /// Query type /// Query response type public interface IQueryHandler where TQuery : IQuery { /// /// Handle the message /// /// Message data /// /// Message response Task Handle(TQuery message, CancellationToken cancellationToken); } For example: .. sourcecode:: csharp public class MyQueryHandler : IQueryHandler { public Task Handle(MyQuery query, CancellationToken cancellationToken) { //Example operation return Task.FromResult("Hello: " + query.QueryData); } } Sending through the mediator ============================ Third, send the query through the mediator: .. sourcecode:: csharp MyQuery query = new MyQuery() { QueryData = "Dementcore" }; string res = await _mediator.Send(query);