My question is about how you handle paging with a WCF data service. The way I want to use it, is execute a query (passing page size and current page), and get back the results of that query and also the paging information like total number of pages, current page number and page size. This paging information is used by the client (which is another service that transforms the result to JSON for a mobile application that consumes it) to handle next/previous buttons.
However, using LINQ on a WCF data service is too limited, it doesn't support the LINQ expression I need.
I tried creating a service operation in the WCF data service, but I can only return IQueryable collections of data entities, so I cannot return a custom entity that also contains paging information.
Is there a way to do implement paging for a WCF data service so that I next to the result I also get back paging information?
EDIT: because of the limitations of WCF data services, I switched to a normal WCF service. To be honest, I don't see why anyone would ever want to use a data service with these severe limitations!
Use
Skip
andTake
to perform client side paging of data from the WCF data service, such as:Where StartIndex is the beginning position of the data you want returned and PageSize is the number of elements max to return.
Have a look at the Paging Provider for WCF Data Services here and here
Unfortunately it seems that WCF data services is way too limited, and the solution for me was to switch to a regular WCF service so that I could use full LINQ and define data contracts myself.