我正在使用Windows Azure移动服务(c#Win RT应用程序)。表“Game”包含“PlayerName”,“PlayerMail”和“PlayerAge”列。
例如:第1行:Tim tim@hotmail.com 21 |第2行:Jan jan@hotmail.com 23
在后面的代码中,我要求在文本框中填充PlayerName等于名称的所有行。 PlayerName只有Tim,只有一行。我想获得该人的PlayerMail并将其放入变量中。我怎么能这样做?
private IMobileServiceTable<Game> todoTable = App.MobileService.GetTable<Game>();
var player = Player.Text
var databynaam = await todoTable.Where(todoItem => todoItem.PlayerName == player).ToCollectionAsync();
答案 0 :(得分:2)
您可以使用Select
操作仅选择该字段:
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();