Search code examples
c#.netwcf-data-servicesodata

OData (WCF Data Services) Continuation on a query that uses projection


I have an OData query that looks like this:

var query = entities.MyObjects.Select(x => new {x.MyObjectID, x.Number, x.Name});

When I run it I get only 100 items back. That is because my server is setup to page at 100 items.

But there are quite a few more and I need them all at once (in just this one occasion).

How can I get them all?

NOTE: I have tried to follow the Continuation examples on the web, but they all use a DataServiceCollection<T>. Since I am using projection, I don't have a valid type to put in there.

I read through this page: How to: Project Data Service Query Results, but it did not help either as it is not using anonymous types.

Is this possible? I don't want to bring back all of the object (it is quite large and there is no need to waste the bandwidth or memory doing that.)


Solution

  • Use Take and Skip with multiple queries.

    Similar too: WCF Data Service - How to set Page Size programmatically?

    var query = entities.MyObjects.Skip(200).Take(100).Select(x => new {x.MyObjectID, x.Number, x.Name});