I'm trying to update a row in a Windows Azure Mobile Services Database with a .NET client using the following code:
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. 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. 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.
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();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.