Specific value from azure mobile services table

有些话、适合烂在心里 提交于 2019-12-25 02:22:22

问题


I have a data table which looks like

id        name          age           emailId 

X         bill           20           bill@abc.com 
y         john           19           bob@abc.com 

on client side application

    public class myTabble { public string Id { get; set; }

[JsonProperty(PropertyName = "name")]
public string name { get; set; }

[JsonProperty(PropertyName = "age")]
public int age { get; set; }

[JsonProperty(PropertyName = "email")]
public string email { get; set; }

I am trying to store the name of the user having email id bob@abc.com by

var names = await todoTable
               .Where(t => t.email == "bob@abc.com")
               .Select(t => t.fname)
              .ToCollectionAsync();

                string myName = Convert.ToString(names);

but it is not working. How can I do this please help.


回答1:


Calling ToCollectionAsync will give you a collection object (an ObservableCollection), one which you can use to bind the results with a UI control (such as a list view). If you want to programmatically get a value, you should use one of the other methods to retrieve data from the table, either ToListAsync or ToCollectionAsync:

var names = await todoTable
    .Where(t => t.email == "bob@abc.com")
    .Select(t => t.fname)
    .ToEnumerableAsync();
var myName = name.FirstOrDefault(); // name will be null if not found


来源:https://stackoverflow.com/questions/21087755/specific-value-from-azure-mobile-services-table

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