Alexander Leyva Caro
Alexander Leyva Caro

Reputation: 1253

How OData works in AspNet MVC without change any code

To enable OData after installing the Microsoft ASP.NET Web API 2.2 package, the only thing to do is add the attribute EnableQuery and return IQueryable.

If the attribute EnableQuery is only metadata, what change in the framework?

I mean, when an request arrive the framework matches the url with the Route Table and then create the controller to manage the request. What does change with OData?

Upvotes: 0

Views: 88

Answers (1)

lencharest
lencharest

Reputation: 2915

EnableQueryAttribute derives from ActionFilterAttribute, which means it can affect the result of an action via its OnActionExecuted method (called internally by Web API). Take a look at the source code to see what EnableQuery is really doing.

Upvotes: 2

Related Questions