【发布时间】:2018-12-28 12:28:45
【问题描述】:
我正在尝试使用 MobileServiceSQLiteStore 同步,但我从不检索在线存储的数据。
实际上,使用在线模式非常有效。但是当我使用 IMobileServiceSyncTable 而不是 IMobileServiceTable 时,即使在推拉操作之后,本地商店也永远不会填充在线数据。
有一个奇怪的地方,当我通过 IMobileServiceSyncTable 插入数据时,我的天蓝色在线数据被填充,并且这些新数据将在本地商店中的新应用启动时正确读取。
这是我的代码示例:
//service client access
this.client = new MobileServiceClient(Constants.ApplicationURL);
//local store definition
this.Store = new MobileServiceSQLiteStore(offlineDbPath);
//intializing table in local store
Store.DefineTable<MYTABLE>();
//Initializing synchronisation context
await CurrentClient.SyncContext.InitializeAsync(Store);
//mapping table
var myTable = CurrentClient.GetSyncTable<MYTABLE>();
//Full synchronisation
await client.SyncContext.PushAsync();
await myTable.PullAsync(null, myTable.CreateQuery());
//Getting results from local store
var results = await myTable.ToListAsync();
因此,此时,结果仍然为空。但我使用 GetTable 而不是 GetSyncTable 获取所有数据。 更准确地说,我有 5 行存储在我的 SQL Azure 表中,通过 Azure AppService 使用 Azure EasyTables 连接。 如果我使用以下代码,一切正常,我成功获得了 5 个结果:
//service client access
this.client = new MobileServiceClient(Constants.ApplicationURL);
//mapping to online easytable
var myTable = client.GetTable<MYTABLE>();
//Getting results from online azure sql database
var results = await myTable.ToListAsync();
奇怪的是,我可以使用 MobileServiceSQLiteStore 填充我的在线数据库。但是,如果我使用同步在线/离线代码重新运行我的应用程序,我将只读取新插入的数据。 所以,有一些东西阻止了本地商店的初始填充,但没有办法找到任何有用的东西。
你有没有注意到这种行为?
我在 MSDN 上发布了这个帖子,但他们把我发到这里: https://social.msdn.microsoft.com/Forums/en-US/9c5db53f-8b64-4a00-85ac-26498a216e7e/never-getting-online-azure-data-using-mobileservicesqlitestore?forum=azuremobile&prof=required
技术环境信息: VS2017,Xamarin.Forms,NetStandard2.0。
感谢您的帮助
【问题讨论】:
标签: sqlite azure xamarin.forms