The RequestModel contains two properties; PageNumber and PageSize. The RequestModerl could contain sort order by certain fields but because this is simple pagination no sorting by fields is supported in this note.
The ResonseModel
The service in question has tree operations:
We are particularly interested in the implementation of ResponseModel
The interesting part is the OrderBy > Skip > Take. Note that in case that the client asks for a page which does not exist the actual page is reset to the last page so we know the records to skip. Note that what is sent to the client has been mapped to a specific DataContract and it was done using a mapping extension very similar to how it was done in A1 Repo: Explicit Mapping Using Extensions Methods Rather than Using AutoMapper.
This little POC is tested using a console application. Note that when a service reference is created the client proxy offers the possibility of using asynchronous programming.
For this note the Adventure2012 database was used. The ORM employed was Entity Framework and the model was created using the Entity Data Model Wizard > Code First from Database.
To Table of contents