我使用Windows Azure构建了一个数据库,目前的目标是使用移动服务在Android应用中查询该数据库。
我构建了一个WCF服务,可以提供我想要的结果,然后意识到您可以直接在Azure站点上创建移动服务。在Azure上创建移动服务并告诉它使用我的Azure数据库后,我没有看到任何地方编写该服务将用于返回数据的查询。我还需要我的WCF服务吗?我会以某种方式将其上传到Azure移动服务吗?我可能在这里错过了一些简单的东西。
答案 0 :(得分:0)
检查this。请参阅“更新应用以使用移动服务进行数据访问”部分。
private MobileServiceClient mClient;
private private MobileServiceTable<ToDoItem> mToDoTable;
mClient = new MobileServiceClient("MobileServiceUrl", "AppKey", this)
.withFilter(new ProgressFilter());
mToDoTable = mClient.getTable(ToDoItem.class);
mToDoTable.where().field("complete").eq(false)
.execute(new TableQueryCallback<ToDoItem>() {
public void onCompleted(List<ToDoItem> result,
int count, Exception exception,
ServiceFilterResponse response) {
if(exception == null){
mAdapter.clear();
for (ToDoItem item : result) {
mAdapter.add(item);
}
} else {
createAndShowDialog(exception, "Error");
}
}
});
另请参阅此blog post。
答案 1 :(得分:0)
您可能会发现此博文有用:How to use Windows Azure Table Storage in Windows Azure Mobile Services。
这显示了如何使用Windows Azure移动服务在Windows Azure表存储之上构建服务,可以从移动客户端应用程序(Windows Phone,Android,Windows应用商店,iOS或HTML 5)访问该服务。不需要您的WCF服务,您可以在移动服务的读取脚本中包含查询。
此处还有另一个示例,说明如何创建移动服务脚本以访问MongoDB数据库而不是SQL Azure或Windows Azure表存储:http://www.contentmaster.com/azure/using-windows-azure-mobile-services-with-a-mongodb-database/