Search code examples
silverlightrepository-patternwcf-ria-services

RIA Services: Should i return IQueryable or IList? and mark as INVOKE? (Following the service and repository patterns)


I have been investigating RIA Services and i pretty much understand what is going on. But if i wish to use the RIA Services like the Service Layer which calls the repository layer then should i not return IList and mark my methods as INVOKE ?

This seems to me like a standard Service Layer call to repository layer. Where repository returns IQueryable and services returns IList

I am very much familiar with these patterns (Service and Repository) but would like to use RIA Services like this.

Otherwise then silverlight would always, in reality, call to the repository directory as it returns IQueryable.

My idea, although i would love some feedback is create another layer on the ria services that returns IQueryable etc - and we call this the Repository pattern.. and then get the Ria Services (Domain Service) methods to always return IList or domain class and mark "ALL" these methods as INVOKE so that we don't need to return IQueryable.

Does this sound good in practise? Really appreciate any feedback

Thanks in advance


Solution

  • If you use Invokes instead of Queries you miss out on some of the cool features of RIA such as the new DomainCollectionView, which requires a LoadOperation to work properly. In reality, whether your methods return IList or IQueryable, execution of the expression is still deferred to the server, so from the client's perspective it probably doesn't make a lot of difference.

    Otherwise then silverlight would always, in reality, call to the repository directory as it returns IQueryable.

    The client doesn't need to know this, so what difference does it make? It's just like any other repository/service implementation - a level of indirection between client and data to save yourself headaches in case of future changes to the system.