Azure离线同步-如何使用“包含" [英] Azure Offline Sync - How to use "Contains"

查看:102
本文介绍了Azure离线同步-如何使用“包含"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Azure表,我想在移动设备上离线同步它,如果我传递单个where子句(如以下

I have an Azure Table and I want to sync it offline on my mobile device, Everything works fine if I pass single where clause such as following

var query = todoTable.CreateQuery().Where(c => c.Id == "some id here");
await todoTable.PullAsync(null, query);

但是我有一个List,其中包含多个ID,例如

But I have a List which contains multiple IDs such as

List<string> IDS = new List<string>();
IDS.Add("Some ID 1");
IDS.Add("Some ID 2");

并且我试图按以下方式在查询中传递该信息,以仅获取具有特定ID的商品

and I am trying to pass that in my query as following to only get items with specific Ids

var query = todoTable.CreateQuery().Where(c => IDS.Contains(c.Id));
await todoTable.PullAsync(null, query);

但这似乎不起作用,

有没有办法做到这一点?

Is there a way to do this?

推荐答案

var query = todoTable.CreateQuery().Where(c => IDS.Contains(c.Id));

var query = todoTable.CreateQuery().Where(c => IDS.Contains(c.Id));

等待todoTable.PullAsync(null,query);

await todoTable.PullAsync(null, query);

据我了解,您的pull操作将针对您的移动后端执行以下请求:

Per my understanding, your pull operation would execute the following request against your mobile backend:

GET https://{your-app-name}.azurewebsites.net/tables/{your-table-name}?$filter=((id eq 'Some ID 1') or (id eq 'Some ID 2'))

测试:

根据我的测试,上述拉动操作可以按我的预期进行.我建议您在调用拉动操作时使用 fiddler 捕获网络跟踪,以确保可以检索到记录符合预期.此外,您可以遵循

Based on my testing, the above pull operation could work as expected on my side. I recommend you use fiddler to capture the network trace when invoking the pull operation to make sure that you could retrieve the records as expected. Moreover, you could follow Debugging the Offline Cache.

更新:

我在C#移动应用程序后端检查了此问题,以缩小此问题的范围.我将Startup.MobileApp.cs下的config.IncludeErrorDetailPolicy设置为IncludeErrorDetailPolicy.Always,以获取详细的错误消息.我发现我可能会遇到以下错误:

I checked this issue on my C# mobile app backend to narrow down this issue. I set config.IncludeErrorDetailPolicy to IncludeErrorDetailPolicy.Always under Startup.MobileApp.cs for retrieving detailed error messages. And I found that I could encounter the following error:

我假设我们可能会点击

I assumed that we may hit the ODataValidationSettings.MaxNodeCount which is used to determine the maximum of the nodes inside the $filter syntax tree. Then, I decorated my action as follows to increase the MaxNodeCount limitation, and found that the query could work as expected.

[EnableQuery(MaxNodeCount =1000)]
public IQueryable<ToDoItem> GetAllTodoItems()

这篇关于Azure离线同步-如何使用“包含"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆