Paging with WCF Data Service

My question is how do you handle paging with WCF data service. The way I want to use it is to execute a query (pass in the page size and current page) and return the results of that query as well as paging information such as the total number of pages, the current page number and the page size. This paging information is used by the client (which is another service that converts the result to JSON for the mobile app that consumes it) to process the next / previous buttons.

However, the use of LINQ in WCF Data Service is too limited, it does not support the LINQ expression that I need.

I tried to create a service in WCF Data Service , but I can only return IQueryable collections of data objects, so I cannot return a custom object that also contains paging information.

Is there a way to do the paging for the WCF data service so that next to the result I also get paging information?

EDIT: Due to limitations of WCF data services, I switched to regular WCF service. To be honest, I don't understand why anyone would ever want to use a data service with these severe limitations!

+2


source to share


3 answers


Unfortunately, it looks like WCF data services are too limited and the solution for me was to switch to a regular WCF service so that I could use the full LINQ and define the data contracts myself.



+3


source


Have a look at the paging provider for WCF Data Services here and here



+2


source


Use Skip

and Take

to perform client-side data paging from a WCF Data Service, for example:

var items = (from i in ctx.MyEntities
             select i).Skip(StartIndex).Take(PageSize)

      

Where StartIndex is the starting data position you want to return and PageSize is the number of max elements to return.

+2


source







All Articles