locked
Howto: Continuation PageSize on navigation properties RRS feed

  • Question

  • If you use continuations and have a rule:

    config.SetEntitySetPageSize("*", 10);
    

    and you want to view all the Orders on a Customer so

    http://localhost/svc.svc/Customers(1)?$select=Name,Orders

    Then the pagesize will chop the Orders result set at 10 records.

     

    How would you access the rest? 

     

     

     

    • Edited by Jif Tuesday, July 27, 2010 1:58 AM
    Monday, July 26, 2010 11:00 PM

Answers

  • You could construct the URL the LoadProperty uses by hand (or by asking the continuation) and modify it by adding some expands.

    But the chattiness is sort of by design (to certain degree), due to server driven paging (SDP). The SDP tries to protect the server by returning only a limited number of results for each request. So if your client needs all the results it will have to issue multiple requests. Now if you need expanded entities as well, the same principle applies to the expanded entities.

    Thanks,


    Vitek Karas [MSFT]
    Wednesday, July 28, 2010 9:48 AM
    Moderator

All replies

  • Hi,

    The projection shouldn't affect the page size. In your case, if you want to get the next set of orders, you need to use the continuation token. Take a look at this page (specifically the Paged Content section):
    http://msdn.microsoft.com/en-us/library/ee358709.aspx

    In the code sample, you will notice the call to GetContinuation. This will allow you to get the rest of the orders.

     

    Thanks,
    Julian

    Tuesday, July 27, 2010 12:14 AM
  • Sorry, I included two concepts there where it was not necessary, I'm talking about continuations and not projections (I changed the previous post).

    There is only a continuation on the root level of the request.  The nav property Orders that is under the Customer does not have a continuation but is still limited to the pagesize of 10 in this case.  How to get the rest of the records is the problem?

    Tuesday, July 27, 2010 2:02 AM
  • And I see from the link that the following code is the suggestion:

    while (nextOrdersLink != null)
    {
      foreach (Order o in c.Orders)
      {
        // Print out the orders.
        Console.WriteLine("\t\tOrderID: {0} - Freight: ${1}",
          o.OrderID, o.Freight);
      }
    
      // Load the next page of Orders.
      var ordersResponse = context.LoadProperty(c, "Orders", nextOrdersLink);
      nextOrdersLink = ordersResponse.GetContinuation();
    }

    LoadProperty is not so nice because I can't expand any of the nav properties with it.  In this example, if an Order has OrderLines then I need to load all the Orders and then perform another query to get the OrderLines for each Order.  Seems a bit chatty.

     

     

     

    Tuesday, July 27, 2010 2:10 AM
  • You could construct the URL the LoadProperty uses by hand (or by asking the continuation) and modify it by adding some expands.

    But the chattiness is sort of by design (to certain degree), due to server driven paging (SDP). The SDP tries to protect the server by returning only a limited number of results for each request. So if your client needs all the results it will have to issue multiple requests. Now if you need expanded entities as well, the same principle applies to the expanded entities.

    Thanks,


    Vitek Karas [MSFT]
    Wednesday, July 28, 2010 9:48 AM
    Moderator