user1951083
user1951083

Reputation: 261

Windows Azure get item from specific column

I'm using Windows Azure Mobile Services (c# Win RT application). Table "Game" consits of columns "PlayerName", "PlayerMail" and "PlayerAge".

e.g.:1st row: Tim [email protected] 21 | 2nd row: Jan [email protected] 23

In code behind I'm asking all the rows where PlayerName equals name filled in the textbox. There is only 1 row where the PlayerName is Tim. I would like to get the PlayerMail of that person and put it in a variable. How can I do this?

private IMobileServiceTable<Game> todoTable = App.MobileService.GetTable<Game>();

var player = Player.Text
var databynaam = await todoTable.Where(todoItem => todoItem.PlayerName == player).ToCollectionAsync();

Upvotes: 0

Views: 911

Answers (1)

carlosfigueira
carlosfigueira

Reputation: 87228

You can use the Select operation to choose only that field:

IMobileServiceTable<Game> todoTable = App.MobileService.GetTable<Game>();
string player = Player.Text;
IEnumerable<string> emails = await todoTable
    .Where(game => game.PlayerName == player)
    .Select(game => game.PlayerMail)
    .ToEnumerableAsync();
string playerMail = emails.FirstOrDefault();

Upvotes: 2

Related Questions