Azure移动服务表中的特定值 [英] Specific value from azure mobile services table

查看:54
本文介绍了Azure移动服务表中的特定值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据表,看起来像

I have a data table which looks like

id        name          age           emailId 

X         bill           20           bill@abc.com 
y         john           19           bob@abc.com 

在客户端应用程序上

    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; }

我正尝试通过以下方式存储电子邮件名为bob@abc.com的用户的名称

I am trying to store the name of the user having email id bob@abc.com by

var names = await todoTable
               .Where(t => t.email == "bob@abc.com")
               .Select(t => t.fname)
              .ToCollectionAsync();

                string myName = Convert.ToString(names);

,但是它不起作用.我该怎么办,请帮忙.

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

推荐答案

调用 ToCollectionAsync 将为您提供一个收集对象(一个ObservableCollection),您可以使用该对象将结果与UI控件绑定(例如列表视图).如果要以编程方式获取值,则应使用其他方法之一从表中检索数据,即 ToListAsync ToCollectionAsync :

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 == "bob@abc.com")
    .Select(t => t.fname)
    .ToEnumerableAsync();
var myName = name.FirstOrDefault(); // name will be null if not found

这篇关于Azure移动服务表中的特定值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆