The more I research about Microsoft framework on ODATA I tend to believe that it is not suited for enterprise application. The framework expects all the database to be directly exposed as ViewModel, even for simple operations like Pagination & sorting.
We would be forced to use stasteful mechanism to persist page numbers rendered to the JavaScript client.
Or am I not understanding Microsoft implmentation of OData correctly?
EDIT-1:
Is ODATA V4 a Stateful Architecture? As promoted by Microsoft patterns team. I do not see any easy path of Migration from Asp.Net Web API (REST) to OData (Sounds STATEFUL) Architecture.
EDIT-2: Paging, sorting & grouping is part of incoming request from the client.
In short the MS Odata server side implementation is not statefull and it can be considered a REST architecture.
You provide paging information in the request. For example, if you wanted 10 items of page 2 you would take the top 10 and skip 10.
As you can see the client/caller specifies the paging, there is no need for the server to track state of the client.
Also adding
$count=true
will return the total number of records based on the passed in filter included in the result set (in the above example there is no filter). This will allow the client to calculate the number of pages there are.Also not true. You can return an
IQueryable<T>
whereT
is your type.T
does not have to be an EF model. For example,returning the following from aDbContext
is acceptable.To further illustrate that point you could also return a hard coded list of objects, although this might not be very likely in production.
There are many resources on all the options for OData. I am not going to include everything here, otherwise I might as well just be creating a 2nd set of documentation.