简体   繁体   English

WCF RIA服务:编写查询

[英]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. 我可能发誓,您可以根据RIA为您生成的Get ...方法来组成查询。 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>'. 错误CS1936:找不到源类型“ 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 注意:我是从MSDN网站上获得的,这里是: http : //msdn.microsoft.com/zh-cn/library/system.servicemodel.domainservices.client.entityquery(v=vs.91).aspx

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 支持LINQ的EntityQuery扩展方法在名称空间中

System.ServiceModel.DomainServices.Client; System.ServiceModel.DomainServices.Client;

So you must add a using clause to your code file before the LINQ extensions will show up. 因此,必须先在代码文件中添加using子句,然后LINQ扩展才会显示出来。

Example: 例:

using System.ServiceModel.DomainServices.Client;

The linq extension methods for that aren't in the normal namespace. 相应的linq扩展方法不在常规名称空间中。 As JMarsch states, you need to bring in System.ServiceModel.DomainServices.Client 正如JMarsch所述,您需要引入System.ServiceModel.DomainServices.Client

Here's the extensions class on msdn: 这是msdn上的扩展类:

http://msdn.microsoft.com/en-us/library/system.servicemodel.domainservices.client.entityqueryable(v=vs.91).aspx http://msdn.microsoft.com/zh-cn/library/system.servicemodel.domainservices.client.entityqueryable(v=vs.91).aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM