1
votes

In my Xamarin iOS PCL app I'm trying to insert a record into my local Sqlite table, have it synced via Azure Mobile Services, and then read it back. Here is the code:

private IMobileServiceSyncTable<Job> jobTable;

public async Task InitializeAsync()
        {
            var store = new MobileServiceSQLiteStore("localdata.db");
            store.DefineTable<Job> ();

            await this.MobileService.SyncContext.InitializeAsync(store);

            jobTable = this.MobileService.GetSyncTable<Job>();

 jobTable = this.MobileService.GetSyncTable<Job>();

            JObject newJob = new JObject ();

            newJob.Add ("Id","job_123");

            jobTable.InsertAsync (newJob);


           this.MobileService.SyncContext.PushAsync();

            var readResult = jobTable.ReadAsync ().Result.AsQueryable();

            var resultList = from data in readResult
                    select data;

            var resultCount = resultList.Count ();
        } 

So far - nothing gets synced up with my Sql Server db (which is on the recieving end of the Mobile Services), and the resultCount remain at 0

I'm sure I do something wrong here, just can't seem to nail what exactly.

-Eugene

1

1 Answers

1
votes

You should use PullAsync instead of ReadAsync. Also, you need to await the call to all of your async method calls, such as InsertAsync, PushAsync, and PullAsync.

See this tutorial for a detailed example: http://azure.microsoft.com/en-us/documentation/articles/mobile-services-xamarin-ios-get-started-offline-data/