开发者

Filtering Asynchronous OData Queries on Windows Phone 7

I am working on an application for Windows Phone 7 that makes asy开发者_开发知识库nchronous queries to OData. I use the following general form for the query:

DataServiceQuery<Entity> query = ourEntities.CreateQuery<Entity>("Entities");
entities.BeginExecute(QueryComplete, query);

I am having trouble adding filters to these queries, though. Using LINQ did not seem to be an option for asynchronous queries, so I tried adding OData filters using the AddQueryOption method mentioned in this article (trying to get results for when the Id is 1):

query.AddQueryOption("$filter", "Id eq 1");

If we take the URL from the async result and paste it into a browser, it works properly and returns the expected result. However, attempting to evaluate the result of the query always seems to result in a NotSupportedException with no message or inner stack trace.

Ideally, I'd like to be able to use LINQ, like Scott Hanselman did in his blog post about OData. If that is not an option for asynchronous data retrieval, how can I achieve filtering on the query?


Currently the LINQ support on the Windows Phone 7 platform is limitted. The previous WCF Data Services client was meant to try what would work and what would not work for our users, but it has its limitations. See this blog post for more details: http://blogs.msdn.com/b/astoriateam/archive/2010/09/27/wcf-data-services-client-library-and-windows-phone-7-next-steps.aspx

In general I would suggest you use the BeginExecute method instead and construct the URL manually without the use of DataServiceQuery class, which as noted in the above blog will not be available in the first official release.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜