Mathias Rönnlund
Mathias Rönnlund

Reputation: 4817

Custom TableController<> offline sync backend for use with Azure Client SDK IMobileServiceSyncTable app

We are developing an Android app with Xamarin and want to use offline sync but we cannot connect our DTOs directly to the database, as is done in almost all examples and the Quickstart solution one can download from the Azure portal.

For now I'm using the ToDo sample app downloaded from the Azure portal, which by default is mapped to the address https://myappname.azurewebsites.net.

I have a WebApi application, whose address I put in the ToDo app's settings and with a catch-all route saw that the app calls the address http://mywebapidev/tables/todoitem. In the WebApi application I added the route /tables/{controller} route and a controller called ToDoItemController, which inherits from TableController.

I also implemented my own DomainManager, which I'm setting in Initialize

public class ToDoItemController : TableController<ToDoItem>
{
    protected override void Initialize(HttpControllerContext controllerContext)
    {
        base.Initialize(controllerContext);
        this.DomainManager = new MyDomainManager();
    }
}

My question is, what do I need to implement (in the controller and elsewhere) for it to be able to work as the backend for Azure Client SDK offline sync?

Upvotes: 0

Views: 355

Answers (1)

Adrian Hall
Adrian Hall

Reputation: 8035

I suggest you read http://aka.ms/zumobook - especially chapter 3. It goes through the process of offline sync rather thoroughly.

Short version though:

  1. You need a DateTimeOffset type in your model so the service can do incremental sync
  2. You need a Version column (opaque) so the service can do conflict resolution.
  3. You need to convert the OData query into LINQ and then LINQ into your specific requirements. This is the hard part.

Upvotes: 1

Related Questions