I am pulling my hair out at this point. I have been working and debugging the code for 4 days but I can't figure out why data isn't inserted into the easy table. Below is my code, and note that SyncAsync() gets called because my breakpoints are hit. However, the call dies at PushAsync() call and it never jumps to catch and just continue on (do other await calls). So I have no idea what the exceptions are. I have also tried to catch all exception by changing the catch block, but no success so far. Please help!
In AzureService class:
static AzureDataService defaultInstance = new AzureDataService();
MobileServiceClient client;
#if OFFLINE_SYNC_ENABLED
IMobileServiceSyncTable<Users> userTable;
#else
IMobileServiceTable<Users> userTable;
#endif
private AzureDataService()
{
this.client = new MobileServiceClient("https://mysubdomain.azurewebsites.net");
#if OFFLINE_SYNC_ENABLED
var store = new MobileServiceSQLiteStore("userstore.db");
store.DefineTable<Users>();
//Initializes the SyncContext using the default IMobileServiceSyncHandler.
this.client.SyncContext.InitializeAsync(store);
userTable = client.GetSyncTable<Users>();
#else
this.userTable = client.GetTable<Users>();
#endif
}
public async Task SaveTaskAsync(Users item)
{
await userTable.InsertAsync(item);
}
#if OFFLINE_SYNC_ENABLED
public async Task SyncAsync()
{
ReadOnlyCollection<MobileServiceTableOperationError> syncErrors = null;
try
{
await this.client.SyncContext.PushAsync();
// The first parameter is a query name that is used internally by the client SDK to implement incremental sync.
// Use a different query name for each unique query in your program.
await this.userTable.PullAsync("users" + DateTime.UtcNow.ToString("O"), this.userTable.CreateQuery());
}
catch (MobileServicePushFailedException exc)
{
if (exc.PushResult != null)
{
syncErrors = exc.PushResult.Errors;
}
}
}
#endif
In Users Class:
public class Users
{
[JsonProperty(PropertyName = "UserName")]
public string UserName { get; set; }
[JsonProperty(PropertyName = "Password")]
public string Password { get; set; }
[JsonProperty(PropertyName = "Email")]
public string Email { get; set; }
[JsonProperty(PropertyName = "id")]
public string id { get; set; }
//[Microsoft.WindowsAzure.MobileServices.Version]
//public string AzureVersion { get; set; }
}
Finally, yes, I have check the table on Azure portal, 30+ times so far. The schema of the easy table matches the User class.
Thanks