Concerning the use of the CQRS pattern in a .NET API I've seen some examples where the request is deserialized directly into the command/query and then it's sent off for handling, like this:
[HttpPost]
public async Task<IActionResult> CreateOrder(CreateOrderCommand command)
{
var result = await _mediator.Send(command);
return Ok(result);
}
In other examples, some kind of dto or request object is instead used and then fed into the constructor of the command/query, like this:
[HttpPost]
public async Task<IActionResult> CreateOrder(CreateOrderDto model)
{
var command = new CreateOrderCommand(model.orderNumber, model.firstName...);
var result = await _mediator.Send(command);
return Ok(result);
}
The first approach looks more appealing to me as it's one less model and line of code. Is there a reason why you might use the second approach and separate the request object from the command object?