Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
First glance on my unofficial Windows Phone SDK for Azure Mobile Services
// in App.xaml.cs
public partial class App : Application
{
public static readonly MobileServiceClient MobileServiceClient;
public static User CurrentUser;
static App()
{
// Get this data from the management portal's quickstart page
// in the 'connect to existing apps' section
MobileServiceClient = new MobileServiceClient(
"https://YOUR_APP.azure-mobile.net/",
"YOUR_APP_KEY"
);
}
// the rest of App.xaml.cs here ...
}
// elsewhere:
MobileServiceTable<TodoItem> todoItemTable = App.MobileServiceClient.GetTable<TodoItem>();
// insert
var item = new TodoItem { Text = "Do this!" };
todoItemTable.Insert(item, (res, err) => {
if (err != null) {
//handle it
return;
}
item = res;
});
// Update (sorry, no typed version yet):
var updates = new JObject();
updates["text"] = "The text";
todoItemTable.Update(updates, err => {
if (err != null) {
//handle it
}
});
// Get all
todoItemTable.GetAll((res, err) => {
if (err != null) {
//handle it
return;
}
foreach (TodoItem in res) {
}
});
// OData query
var query = new MobileServiceQuery()
.Filter("text eq 'whatever'")
.Top(1)
.Skip(2)
.OrderBy("id desc");
todoItemTable.Get(query, (res, err) => {
if (err != null) {
//handle it
return;
}
foreach (TodoItem in res) {
}
});
// delete
testStuffTable.Delete(item.Id, err => {
if (err != null) {
//handle it
}
});
// login to Azure Mobile Services with the AuthenticationToken returned
// from LiveAuthClient or the LiveLoginButton's SessionChanged event
App.MobileServiceClient.Login(e.Session.AuthenticationToken, (userId, err) => {
// do something with userId, perhaps call to LiveConnect for user details, etc.
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.