Reputation: 2127
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.
I built a WCF service that gives me my desired results, then realized you can create a mobile service directly on the Azure site. 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. Do I still need my WCF service? Do I upload it into the Azure mobile service somehow? I'm probably missing something simple here.
Upvotes: 1
Views: 682
Reputation: 2331
You may find this blog post useful: How to use Windows Azure Table Storage in Windows Azure Mobile Services.
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.
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/
Upvotes: 0
Reputation: 19311
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.
Upvotes: 0