Giter VIP home page Giter VIP logo

azure-mobile-csharp-sdk's Introduction

azure-mobile-csharp-sdk

Experimental c# SDK for Azure Mobile Services that is platform agnostic

In your entry class, or anywhere else visible (eg App.xaml.cs, Main() etc.):

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 ...
}

Grab a table reference (typed - you can use the non-generic method and get a Table that works with JObject):

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:

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

Use, abuse, and report back !

azure-mobile-csharp-sdk's People

Contributors

kenegozi avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.