I'm writing a WebApi method that returns the HttpResponseMessage type.
I have a query that returns a dynamic type that would return the query for the data because it is different information.
The return of the data ends up with an error, but Visual Studio complained about problems with the code. But I noticed something curious
Error message in Visual Studio
Error CS1973 'HttpRequestMessage' has no applicable method named 'CreateResponse' but appears to have an extension method by that name. Extension methods can not be dynamically dispatched. Consider casting the dynamic arguments or calling the extension method without the extension method syntax.
If I put the code in the following format:
Allowed
var retorno = new { cupons = Api.Consultar(codigo) };
return Request.CreateResponse(HttpStatusCode.OK, retorno);
Not allowed
var retorno = Api.Consultar(codigo);
return Request.CreateResponse(HttpStatusCode.OK, retorno);
Assume that Api.Consult () returns an object of type dynamic
What is the difference between these two codes where one is accepted and another is not?