问题
I am trying to update a column in Azure Mobile Services on Windows Phone 8 app. The table stores user data and I want to find the user having a specific email and password and then update a column of it. Currently I have:
IMobileServiceTable<Item> table = App.MobileService.GetTable<Item>();
var account = table
.Where(Item => Item.Email == _email_ && Item.Password == _pass_).
Take(1).ToListAsync();
List<Item> list = account;
list[0].Pursue = pursue; // the value I want to assign
Name of the column I want to update is 'Pursue'. What should I do after this phase?
table.UpdateAsync(account);
I tried the line above but I get an error (Also the change is applied to 'list'). Any suggestions? Thanks.
回答1:
I finally figured it out. I added async keyword when defining the class (required to use await).
IMobileServiceTable<Item> table = App.MobileService.GetTable<Item>();
var account = table
.Where(Item => Item.Email == _email_ && Item.Password == _pass_).
Take(1).ToListAsync();
List<Item> list = await account;
list[0].Pursue = pursue;
await table.UpdateAsync(list[0]);
来源:https://stackoverflow.com/questions/18403182/updating-windows-azure-mobile-service-table-entries