Search code examples
c#.netsilverlightwcf-ria-services

RIA Services Via Silverlight Where & Orderby


When I query a database via RIA Services, for example...

OrderWorkflowSLWCFRIA.Web.OrderWorkflowDomainContext db
   = new OrderWorkflowSLWCFRIA.Web.OrderWorkflowDomainContext();

db.Load(db.getWorkflowbyNameQuery(strCurrentLineText, intCustomerId)
     .Where(Workflow => Workflow.UserSelectable == true), load => { }, null);

... Is there any difference between passing parameters to the underlying Domain Service and doing where and orderby subqueries on the domain service side vs specifying them on the client side. I've always thought I should perform it on the domain service side under the assumption that doing the subquery at the client would load all of the data on the client side before doing the subquery, but I have read things that lead me to believe the subquery is actually passed through to the domain service. Is this true or not?


Solution

  • I suppose that with the term "subquery" you intend the Where and OrderBy clause. Well, yes, you are usually right, filtering client side generally force the server to returns everything then things will be filtered/ordered client side, but one of the main goal of WCF Ria services is indeed to make possible to define filtering,ordering and even grouping, on client side, then execute them on server side.

    Basically there's code between client and server that "serialize" your LINQ Expressions over the wire, then "deserialize" it on server side.

    Please note that the terms "serialize" and "deserialize" are not correct in this context, but I think they make the point. Also, keep in mind that there are things that are not implemented on this process, so you can't for instance query a domainservice using nested condition, like, Any()