I'm using Azure Mobile services to sync offline data in a wpf mvvm app. When the app is online CRUD works fine, but when going offline and adding a new record and deleting it wil give this Error:
Message = "The item is in inconsistent state in the local store. Please complete the pending sync by calling PushAsync() before deleting the item."
I also tried purging the record but it will return
The table cannot be purged because it has pending operations.
Deleting:
try
{
await _client.GetSyncTable<TEntity>().DeleteAsync(Model);
await _client.SyncAsync();
}
catch (InvalidOperationException invex)
{
var query = _client.GetSyncTable<TEntity>().CreateQuery().Where(el => el.Id == Model.Id);
await _client.GetSyncTable<TEntity>().PurgeAsync($"purgeEtBla", query,true,CancellationToken.None);
await _client.SyncAsync();
}
Adding:
var entity = _mapper.Map<TEntity>(EntityViewModel);
await _client.GetSyncTable<TEntity>().InsertAsync(entity);
_list.AddEntity(entity);
window?.Close();
await _client.SyncAsync();