In short, the server-side implementation of MS Odata is not statefull and can be considered a REST architecture.
We will be forced to use a static mechanism to save page numbers displayed to the JavaScript client.
In the request, you provide the swap information. For example, if you want 10 elements of page 2, you should take the top 10 and skip the 10.
odata-url/?$count=true&$top=10&$skip=10
As you can see, the client / caller indicates paging, the server should not monitor the status of the client.
Also, adding $count=true will return the total number of records based on the passed to the 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.
The structure expects the entire database to be directly opened as a ViewModel ...
Also not true. You can return an IQueryable<T> , where T is your type. T does not have to be an EF model. For example, returning the next from a DbContext .
public IQueryable<SomeEntity> Get() { return dbContext.SomeEntities .Where(x => optionalPreFiltereExpression) .Select(x => new SomeDTO(){ Prop1 = x.Prop1, Collection1 = x.CollectionOfInterest,
To illustrate this point, you can also return a hard list of objects, although this may be unlikely in production.
public IQueryable<SomeEntity> Get() { return new List<SomeDTO>(){ new SomeDTO(){ Prop1 = 5, Prop2 = "Hi there"
There are many resources for all OData options. I am not going to include everything here, otherwise I could just create a second set of documentation.