Bedant
Bedant

Reputation: 326

Specific value from azure mobile services table

I have a data table which looks like

id        name          age           emailId 

X         bill           20           [email protected] 
y         john           19           [email protected] 

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 [email protected] by

var names = await todoTable
               .Where(t => t.email == "[email protected]")
               .Select(t => t.fname)
              .ToCollectionAsync();

                string myName = Convert.ToString(names);

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

Upvotes: 0

Views: 161

Answers (1)

carlosfigueira
carlosfigueira

Reputation: 87323

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 == "[email protected]")
    .Select(t => t.fname)
    .ToEnumerableAsync();
var myName = name.FirstOrDefault(); // name will be null if not found

Upvotes: 1

Related Questions