PhoenixFirenzy
PhoenixFirenzy

Reputation: 57

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, i.e. 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.

Upvotes: 0

Views: 57

Answers (1)

Arindam Nayak
Arindam Nayak

Reputation: 7462

You can do it like this.

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

Upvotes: 1

Related Questions