locked
WCF Ria Services and Paging RRS feed

  • Question

  • Hi everyone,

    We are developing an internal CRM system using Lightswitch 2013 deskop client and we wanted use WCF RIA services as the only datasource. I was able to implement all the basic CRUD operations in WCF RIA service and it works fine.

    I was able to override the Count<T> method in the DomainServiceClass and I am able to navigate to different pages in my Grid that displays a list of Customers. (IQueryable<Customer> GetAllCustomers())

    Now my question is how is the paging handled on the LightSwitch Desktop side?

    The reason why I ask is every time I had move to different Page, IQueryable<Customer> GetAllCustomers() method is called. Is it loading all the customers and then applying the filter on the client side or Is there any magic happening that I am not aware of?

    If that is the case, Is there any way to implement / customize paging logic so that I do not have to download all the records every time I move to a different page.

    Please advice or point me some resources regarding this area. 

    I appreciate any suggestions.

    Thank You,


    Friday, February 28, 2014 12:38 AM

Answers

  • Hi, you should not have to do anything as long as your list method returns an IQueryable and internally in that method uses an entity framework based IQuearyable in turn for example. Paging should automatically happen server side and only the current page should come down to the client. So the GetAllCustomers() should indeed be called for each page. If you run an SQL server trace you should see the query only loading the current page.

    Regards, Xander. My Blog

    • Marked as answer by uday_zyto Friday, February 28, 2014 3:41 AM
    Friday, February 28, 2014 1:21 AM

All replies

  • Hi, you should not have to do anything as long as your list method returns an IQueryable and internally in that method uses an entity framework based IQuearyable in turn for example. Paging should automatically happen server side and only the current page should come down to the client. So the GetAllCustomers() should indeed be called for each page. If you run an SQL server trace you should see the query only loading the current page.

    Regards, Xander. My Blog

    • Marked as answer by uday_zyto Friday, February 28, 2014 3:41 AM
    Friday, February 28, 2014 1:21 AM
  • Hi, you should not have to do anything as long as your list method returns an IQueryable and internally in that method uses an entity framework based IQuearyable in turn for example. Paging should automatically happen server side and only the current page should come down to the client. So the GetAllCustomers() should indeed be called for each page. If you run an SQL server trace you should see the query only loading the current page.

    Regards, Xander. My Blog

    @Xander, Thank you for your information. It makes complete sense to me now. 

    Now I have a little bit complex scenario. What if IQueryable<Customer>GetAllCustomers() calls a WebAPI service methods that returns a list of customers.

    How can we implement paging in this scenario? Is there any way where I can extract paging information in GetAllCustomers() method so that I can pass it to the WebAPI service method.

    I hope I am clear enough.

    Thanks in advance.

    Uday

    Friday, February 28, 2014 4:03 AM
  • @Uday, you are very clear, but unfortunately the answer is that I have not found a way to intercept the paging parameters at all.

    One potentially complex way, and I have not done that yet, could be to implement your own IQueryable provider that you wrap around that Web APi call in the backend to allow you to intercept the paging parameters.


    Regards, Xander. My Blog

    Friday, February 28, 2014 4:08 AM
  • @Xander, Thanks again for your input. I will keep exploring.

    I guess I will have to implement my own IQueryable provider. I will post here I find a solution for this scenario.

    -Uday

    Friday, February 28, 2014 4:16 AM
  • Uday

    You could solve this problem?
    Sunday, May 3, 2015 3:26 PM