Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
300
VirtualCollection and Best Practices for Paging and Querying
posted

I am looking for a best practices or sample showing how a user would query for varying collection counts in the ui and adjust the "AnctipatedSize" property of a virtual collection accordingly to reflect proper total pages.

For example, we use EntityQueries in RIA, should the query be executed and returned in total to a viewmodel private collection to get the actual count and adjust the anticipated size (to get a correct page count), then using SkipTake against that private cache for paging?

Thanks

  • 300
    posted in reply to [Infragistics] Vlad Zagorski

    The DataPage model, assuming it is what was presented here, is a potential solution yet I am wondering what can be done with EntityQueries in WCF RIA.  You have another presentation that I would like to see expanded upon to show how to better deal with the server processing vs silverlight client and paging, while using EntityQueries and VirtualCollections. 

    Now whether the DataPage<T> response model should/could be combined with the RIA methods on the DomainService, and requests to page go to the service on each page.

    Or do what I did and return the complete result set to a ViewModel and have the count done there by setting IncludeTotalCount = true on the initial EntityQuery and just use the VirtualCollection to handle the rendering of the prefectched data to the grid with linq.

    I just would like to know your thoughts, hope I haven't confused matters.

    Regards,

    Adam

     

  • 9836
    posted

    I'm checking if you have any more questions or concerns regarding the virtual collection.

    Thanks,

  • 3071
    Suggested Answer
    posted

    Hi,
    Let's use the VirtualCollection as a source for a grid.
    The grid access the first page and the VirtualCollection requests data from the application.
    The application can use a WCF service to request items from the server when VirtualCollection fires ItemsDataRequested.
    The GetDataPage is a sample method that returns a data page:
      public DataPage GetDataPage(int startIndex, int count, ...)
    The DataPage class has three properties:
      DataItems  - the records
      StartIndex - the index of first item that the VC requests
      DataCount  - the total number of items
    In a DataPageCompleted eventhandler the application calls the LoadItems method:
      _virtualCollection.LoadItems(e.Result.StartIndex, e.Result.DataItems);
      if (e.Result.DataCount > -1)
      {
        // here the application can set the actual count
        _virtualCollection.AnticipatedCount = e.Result.DataCount;
      }
    Hope this helps
    Regars,
    Marin