Search code examples
c#silverlight-4.0wcf-ria-services

WCF RIA Services: Composing a query


I could have sworn that you could compose a query based upon the Get... methods that RIA generates for you. Like this:


EntityQuery<Address> query = from q in this.Context.GetAddressesQuery()
    where q.ZipCode == "aZipCode"
    select q;
this.Context.Load(query)
...

However, when I try, I'm getting a compile error:

error CS1936: Could not find an implementation of the query pattern for source type 'System.ServiceModel.DomainServices.Client.EntityQuery<TheNamespace.Address>'. 'Where' not found.

Any idea what I'm doing wrong?

Note: I'm getting this from the MSDN site, here: http://msdn.microsoft.com/en-us/library/system.servicemodel.domainservices.client.entityquery(v=vs.91).aspx


Solution

  • I answered my own question, and I will post it here, in case it saves someone else some time. The extension methods for an EntityQuery that support LINQ are in the namespace

    System.ServiceModel.DomainServices.Client;

    So you must add a using clause to your code file before the LINQ extensions will show up.

    Example:

    using System.ServiceModel.DomainServices.Client;