简体   繁体   English

使用Azure数据库的Android Azure移动服务

[英]Azure mobile service for Android using Azure database

I have built a database using Windows Azure, and current goal is to use a mobile service to query that database in an Android app. 我已经使用Windows Azure构建了一个数据库,当前目标是使用移动服务在Android应用程序中查询该数据库。

I built a WCF service that gives me my desired results, then realized you can create a mobile service directly on the Azure site. 我构建了一个WCF服务,它给了我想要的结果,然后意识到您可以直接在Azure站点上创建移动服务。 After creating the mobile service on Azure and telling it to use my Azure db, I don't see anywhere to write a query that the service will use to return data. 在Azure上创建移动服务并告诉它使用我的Azure数据库后,我看不到任何地方写该服务将用于返回数据的查询。 Do I still need my WCF service? 我还需要WCF服务吗? Do I upload it into the Azure mobile service somehow? 是否以某种方式将其上传到Azure移动服务中? I'm probably missing something simple here. 我可能在这里缺少一些简单的东西。

Check this out. 检查这个出来。 See the "Update the app to use the mobile service for data access" section. 请参阅“更新应用程序以将移动服务用于数据访问”部分。

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

Also, see this blog post . 另外,请参阅此博客文章

You may find this blog post useful: How to use Windows Azure Table Storage in Windows Azure Mobile Services . 您可能会发现此博客文章很有用: 如何在Windows Azure移动服务中使用Windows Azure表存储

This shows how you can use Windows Azure Mobile Services to build a service on top of Windows Azure table storage that can be accessed from a mobile client app (Windows Phone, Android, Windows Store, iOS, or HTML 5. You don't need your WCF service, you can include the query in the Read script in your Mobile Service. 这说明了如何使用Windows Azure移动服务在Windows Azure表存储之上构建服务,该服务可以从移动客户端应用程序(Windows Phone,Android,Windows Store,iOS或HTML 5)访问。您的WCF服务,您可以在移动服务的“ 读取”脚本中包含查询。

There is another example here that shows how to create Mobile Services scripts to access a MongoDB database instead of SQL Azure or Windows Azure Table storage: http://www.contentmaster.com/azure/using-windows-azure-mobile-services-with-a-mongodb-database/ 这里还有另一个示例,显示了如何创建移动服务脚本以访问MongoDB数据库而不是SQL Azure或Windows Azure表存储: http : //www.contentmaster.com/azure/using-windows-azure-mobile-services-与一个mongodb数据库/

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

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