Windows azure移动服务 - 选择具有匹配ID的多个项目

时间:2014-04-10 14:01:49

标签: android list azure cloud where

我在使用Windows Azure移动服务时遇到了一些麻烦。我正在编写一个Android应用程序并使用移动服务jar。

目前我正在使用以下代码选择具有匹配ID的对象:

for(int i = 0; i < toBeFetched.size(); i++){

        final Sync curr = toBeFetched.get(i); 

        table.where().field("id").eq(toBeFetched.get(i).row_id).execute(new  TableQueryCallback<Inventory>() {

            @Override
            public void onCompleted(List<Inventory> inventoryRows, int arg1, Exception e,
                    ServiceFilterResponse arg3) {

                if(e == null){
                    if(curr.action.equals("insert")){
                        insertInventoryRow.add(inventoryRows.get(0)); 
                    }else if(curr.action.equals("update")){
                        updateInventoryRow.add(inventoryRows.get(0)); 
                    }

                    DataRowFetched(); 
                }else{
                    e.printStackTrace(); 
                }
            }
        }); 
    }

但是,这会在列表中的每个项目上创建一个新套接字,因此这样做不会很好。有没有办法从本地对象列表中选择具有匹配id的对象?

最好我只想打一个电话并获得一份返回的库存行列表。

1 个答案:

答案 0 :(得分:0)

您可以使用脚本来获取所选ID的对象。通过查询发送参数。此参数将包含您要选择的id的值,您还可以将toBeFetched.size()作为参数发送,并选择所需的顶级结果。 这个link可以帮到你很多