因此,我从同步表中提取了一个数据对象列表,如下所示:
public class AzureMobileService
{
public MobileServiceClient Client { get; private set; }
private IMobileServiceSyncTable<Debt> debtTable;
public async Task Initialize()
{
if (Client != null)
{
return;
}
Client = new MobileServiceClient("https://ajhmobile.azurewebsites.net");
var path = Path.Combine(MobileServiceClient.DefaultDatabasePath, "ajhmobile.db");
var store = new MobileServiceSQLiteStore(path);
store.DefineTable<Debt>();
await Client.SyncContext.InitializeAsync(store, StoreTrackingOptions.NotifyLocalAndServerOperations);
debtTable = Client.GetSyncTable<Debt>();
}
public async Task SyncAsync()
{
try
{
await Client.SyncContext.PushAsync();
await debtTable.PullAsync(
"all",
this.debtTable.CreateQuery());
}
catch (MobileServicePushFailedException exc)
{
// handle resolve
}
}
public async Task<List<Debt>> GetAllDebts()
{
await Initialize();
await SyncAsync();
return await debtTable.ToListAsync();
}
}
但是,如果我从数据库中删除所有债务数据并运行同步刷新,它仍然会返回记录,就好像它没有访问API并寻找新的数据一样。
是否有什么事情我做得不对,或者只是不了解同步表应该如何工作?
我认为当我尝试同步数据时,如果我在本地有记录,但服务器不再有记录,它应该不会返回结果,对吗?