Can someone explain me when I should inherit my controller form ODataController
vs ApiController
?
The question is caused by the fact that results returned by ApiController
can be filtered with OData query.
If I apply QueryableAttribute
to controller's methods, query is processed even if action returns IEnumerable
.
However without this attribute but with the call config.EnableQuerySupport()
, query is processed only if method returns IQueryable
.
I think it is not consistent behavior. WebAPI documentation and examples imply that controller must inherit from ODataController
. And I'm a little confused.
Either ApiController
accidentally
and partially supports part (at least $skip, $filter and $top) of OData protocol. Or this is by design and I need ODataController for complete ODataSupport.
The real problems is that my service exposes DTOs, not POCOs. There may be no one to one mappings. There's need to convert OData query against DTOs to EF query against POCOs.
Now just playing with OData. I retrieve entities and convert them to DTOs. Admittedly, this is not very performant to get all of them from DB for each request yet tolerable for experiments. But there's definitely no need to return all entities to the client if it requires some filtered subset of DTOs.
OData query started working out of the box with ApiController and Querayble attribute, but the aforementioned inconsistency makes me thing I doing something wrong.