0
votes

I have created an OData wrapper layer to my existing data engine. All operations including: sorting filtering and paging are passed directly to my existing engine and retrieve the needed data.

problem is with the paging: second page results are retrieved from my existing engine, but later odata skips the amount of "skip=" and sends empty collection to the client. for example: I am paging "Products", there are 100 in the DB. First page gets 10 to the server, skips 0 and sends the 10 to the client. second page gets 10 to the server, skips 10 and sends nothing to the customer.

Is there a way around this?

p.s. Page size my vary according to client request. I cannot write it hardcoded on the server.

1
Could you please post the URL queries for the first and second page? Also the expression tree executed against your provider for these queries would help as well. - Vitek Karas MSFT
first page query:/Products?&$orderby=product_id asc&$top=10 second page query: /Products?&$orderby=product_id asc&$top=10&$skip=10 - user355289
That looks correct (From the client perspective). So you're saying that even if the query has $skip=10, WCF DS actually skips over 100 rows? Could you please check what is the query (LINQ expression tree) executed against your custom provider for the second query? - Vitek Karas MSFT
No, It skips 10. but after I retrieved records 11-20 all I have to in my server is 10 records, and they are skipped... I will try to get a string out of the expression when debugging. - user355289
I am trying to get something out of System.Linq.Expressions.Expression that I can post here, but not sure where to look as it seems very complex . so my real question here is - how do I read System.Linq.Expressions.Expression and how do I change it to remove the "skip" part - user355289

1 Answers

0
votes

I found this method call in my code and added the first 2 lines:

public IQueryable<TElement> CreateQuery<TElement>(Expression expression)
    {
        if (expression.ToString().Contains(".Skip("))
            expression = (expression as MethodCallExpression).Arguments[0];

        return new DSPLinqQuery<TElement>(this, expression);
    }

this way the larger expression being built will not contain skip(10)