Updating Windows Azure Mobile Service Table Entries

◇◆丶佛笑我妖孽 提交于 2019-12-24 14:24:18

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!