Windows Azure从特定列获取项目

本文关键字:获取 项目 Azure Windows | 更新日期: 2023-09-27 18:16:43

我正在使用Windows Azure移动服务(c# Win RT应用程序)。表"Game"由"PlayerName", "PlayerMail"answers"PlayerAge"三列组成。

。:第一行:Tim tim@hotmail.com 21 |第二行:Jan jan@hotmail.com 23

在代码后面,我问所有行PlayerName = name填充在文本框中。只有一行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();

Windows Azure从特定列获取项目

您可以使用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();