c# - 从 Windows Azure 存储检索数据

标签 c# windows-phone-8 odata azure-storage azure-mobile-services

如何查询我的 Windows Azure 存储,例如:

(SELECT Name FROM User WEHRE DeviceID = App.Current.DeviceID)  

尝试过,似乎不起作用

var Name = await App.MobileService.GetTable<User>()
    .Select(User => User.Name)
    .Where(User => User.DeviceID == App.Current.DeviceID); 

但是我可以根据id查询表

 var Name = await App.MobileService.GetTable<User>().LookupAsync(id);

是否有类似的方法可以根据字符串(例如电话 DeviceID)而不是整数 id 来查询表?

用户类别

public class User
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string DeviceID { get; set; }
    }

最佳答案

Where方法的结果仍然是一个查询对象,它还不是对象本身。您需要调用 ToListAsyncToEnumerableAsync 之一来实际发出请求:

var Name = (await App.MobileService.GetTable<User>()
    .Where(User => User.DeviceID == App.Current.DeviceID)
    .Select(User => User.Name)
    .ToEnumerableAsync()).FirstOrDefault();

关于c# - 从 Windows Azure 存储检索数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17510063/

相关文章:

c# - Windows 手机 : need to check Wi-Fi repeatedly

linq - 使用 OData 和 LINQ 获取链接集合的计数

c# - OData 无法序列化空资源

c# - 我怎样才能快速计算字符串出现在字符串列表的给定部分中的频率?

c# - 验证 Gridview

audio - Wp8背景音乐播放

c# - 任务状态 :Waiting for activation -DownloadStringTaskAsync -WP8

c# - 嵌套 $expands 的 Asp.net WebApi OData V4 问题

c# - 使用 Neo4jClient 的对象关系映射

c# - WPF 使用 DataBinding 根据其值设置标签背景