简体   繁体   中英

Azure Mobile Services - Updating an Entry in the Database

I am trying to update an entry in a table called Request. This table contains columns such as "Name" and "Accepted". I only want to update the "Accepted" field (which holds a boolean value) so that it becomes true. I only want it to be updated if certain conditions are met, ie the "Name" in the database is the same as that in a textbox.

private IMobileServiceTable<Request> requestTable= App.appClient.GetTable<Request>();
private MobileServiceCollection<Request, Request> requests;

requests= await requestTable
        .Where(c => c.Name == txtName.Text)
        .ToCollectionAsync();

//what should I put here to update Accepted to true?

await requestTable.UpdateAsync(requests);

How can I modify this code so that it will update Accepted to true, but only for the rows where the name matches?

Any help would be appreciated, thank you.

您可以这样做。

codes.ForEach(p => p.Request = true);

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.

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