I am trying to push row changes to the Azure server from a Windows Universal app. The data is stored in a local SQlite Db and I used Reflection to select the fields to perform the update as seen in the code below.
private async void Save_Click(object sender, RoutedEventArgs e)
{
var rdlogs = await readingLogTable
.Where(r => r.ReadingLogDate == Convert.ToDateTime(pageLogDate.Text) && r.ReadingTime == pageReadingTime.Text)
.ToCollectionAsync();
var rdlog = rdlogs.FirstOrDefault();
if (rdlog != null)
{
PropertyInfo field = typeof(ReadingLog).GetRuntimeProperty(pageTitleUniqueID.Text);
double value = Convert.ToDouble(tbReadingValue.Text);
if (field != null)
{
field.SetValue(rdlog, value);
}
await readingLogTable.UpdateAsync(rdlog);
}
}
The above code works for string fields but when integers/decimals/floats/double are modified locally offline, and a PushAsync/ExecuteAsync is executed when online, the changes do not get updated to the Azure server even though the local SQlite DB was modified. Additionally, after the push is sent to the Azure server and fails, the modified number fields in the rows on the local SQlite DB is reverted back and updated to match the Azure server fields. No errors are displayed.
I followed the Todo Offline Mobile Services sample which handles sync conflicts between the local offline store and the Mobile Service database in Azure.
Thanks for you help in advance.
Aucun commentaire:
Enregistrer un commentaire