简体   繁体   English

Azure脱机同步-如何使用“包含”

[英]Azure Offline Sync - How to use “Contains”

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 我有一个Azure表,并且想在移动设备上离线同步它,如果我通过单个where子句,例如

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

But I have a List which contains multiple IDs such as 但是我有一个包含多个ID的List ,例如

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

and I am trying to pass that in my query as following to only get items with specific Ids 我试图按照以下方式在查询中传递该信息,以仅获取具有特定ID的商品

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

But this seems not to be working, 但这似乎不起作用,

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));

await todoTable.PullAsync(null, query); 等待todoTable.PullAsync(null,query);

Per my understanding, your pull operation would execute the following request against your mobile backend: 据我了解,您的pull操作将针对您的移动后端执行以下请求:

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

TEST: 测试:

在此处输入图片说明

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 . 此外,您可以按照调试脱机缓存进行操作

UPDATE: 更新:

I checked this issue on my C# mobile app backend to narrow down this issue. 我在C#移动应用后端检查了此问题,以缩小此问题的范围。 I set config.IncludeErrorDetailPolicy to IncludeErrorDetailPolicy.Always under Startup.MobileApp.cs for retrieving detailed error messages. 我在Startup.MobileApp.cs下将config.IncludeErrorDetailPolicy设置为IncludeErrorDetailPolicy.Always ,以获取详细的错误消息。 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. 我假设我们可以点击ODataValidationSettings.MaxNodeCount ,它用于确定$ filter语法树内节点的最大值。 Then, I decorated my action as follows to increase the MaxNodeCount limitation, and found that the query could work as expected. 然后,我按照以下方式装饰了我的操作以增加MaxNodeCount限制,并发现查询可以按预期工作。

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

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

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