简体   繁体   English

如何在Android中从Azure移动服务中选择所有列

[英]How to Select All Columns from Azure Mobile Service in Android

I am using the .Net backend for Azure Mobile Service. 我将.Net后端用于Azure移动服务。 I can successfully run the following query, and it returns all items from the database however it only returns the items with their IDs and no other columns are returns, they are all set to null 我可以成功运行以下查询,它从数据库返回所有项目,但是只返回具有其ID的项目,没有其他列返回,它们都设置为null

TableName.execute(new TableQueryCallback<ClassName>() {
            @Override
            public void onCompleted(List<ClassName> result, int count,
                                    Exception exception, ServiceFilterResponse response)

So do I need to supply a select filter or should I be using the TableOperationsCallback? 因此,我需要提供一个选择过滤器还是应该使用TableOperationsCallback? There is no error, it just returns all the columns as null except for the id column 没有错误,它只是将所有列返回为空,除了id列

Thanks 谢谢

Make sure that the casing of the fields match between the client and the server. 确保客户端和服务器之间的字段的大小写匹配。 By default the .NET backend will make all properties camel-case, so that if you have this class: 默认情况下,.NET后端将使所有属性均为驼峰式,因此如果您具有此类:

public class Person : EntityData
{
    public string Name { get; set; }
    public int Age { get; set; }
}

Then the JSON response in a GET operation will look something like this: 然后,GET操作中的JSON响应将如下所示:

[
    { "id":"the-first-id", "name":"John Doe", "age":33 },
    { "id":"the-first-id", "name":"Jane Roe", "age":34 }
]

So you need to define in your Android application a type where the field is either named in lower case, or properly tagged with the @SerializeName annotation, like in the example below (you don't need to do that for the id property as it's special-cased by the SDK): 因此,您需要在Android应用程序中定义一种类型,该字段可以用小写字母命名,也可以使用@SerializeName批注正确标记,例如下面的示例(因为id属性不需要这样做, SDK特例):

public class Person {
    @SerializedName("id")
    public String Id;

    @SerializedName("name")
    public String Name;

    @SerializedName("age")
    public String Age;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM