[英]UpdateAsync not Working for Azure Mobile Services
I'm trying to update a row in a Windows Azure Mobile Services Database with a .NET client using the following code: 我正在尝试使用以下代码使用.NET客户端更新Windows Azure移动服务数据库中的行:
List<TodoItem> myItemsList = await todoTable.Where(todoItem => todoItem.XID == 1).ToListAsync();
TodoItem myItem = myItemsList.First();
myItem.TITLE = "New Title";
await myClient.GetTable<TodoItem>().UpdateAsync(myItem);
The XID attribute is just my own integer key that I've added, different to the required guid. XID属性只是我自己添加的整数键,与所需的guid不同。 The problem is the update isn't going through. 问题是更新没有通过。 Some things to note are: 需要注意的一些事情是:
For now I'm making do with running the DeleteAsync command, followed by the InsertAsync and that does the trick. 现在,我要先运行DeleteAsync命令,然后再运行InsertAsync,然后就可以了。 But I'm baffled as to why the UpdateAsync command isn't working for me, and why when it does execute it refreshes the 'myItem' instance with the original data. 但是我对为什么UpdateAsync命令对我不起作用以及为什么在执行时会用原始数据刷新“ myItem”实例感到困惑。
Not sure at all but if you are desperate try to change : (no reputation for comment) 完全不确定,但是如果您不顾一切,请尝试更改:(无评论声望)
List<TodoItem> myItemsList = await todoTable.Where(todoItem => todoItem.XID == 1).ToListAsync(); TodoItem myItem = myItemsList.First();
to : 至 :
TodoItem myItem = todoTable.Where(todoItem => todoItem.XID == 1).FirstOrDefault();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.