【问题标题】:Azure Mobile Services PullAsync() Not Filling Sync TableAzure 移动服务 PullAsync() 未填充同步表
【发布时间】:2015-12-17 13:34:14
【问题描述】:

所以我有一个名为Profile 的远程表,它已经创建了多个条目。现在我正在尝试将离线功能集成到我的应用程序中。截至目前,我的代码中的 PushAsyncPullAsync 方法存在问题。

我希望能够通过调用PullAsync 将远程表中的所有数据复制到本地表中,尽管它不会引发任何异常,但它也不会填充我的表。这是我的意思的一个例子。

        var db = new SQLiteConnection("syncstoreTEMP.db");
        var store = new MobileServiceSQLiteStore("syncstoreTEMP.db");
        store.DefineTable<Profile>();
        MobileService.SyncContext.InitializeAsync(store).Wait();
        var remoteValues = MobileService.GetTable<Profile>()
            .ToListAsync()
            .Result;
        MobileService.GetSyncTable<Profile>()
            .PullAsync(null, MobileService.GetSyncTable<Profile>().CreateQuery())
            .Wait();
        var localValues = MobileService.GetSyncTable<Profile>()
            .ToListAsync()
            .Result;

当我运行此代码时,remoteValues 的总长度为 5,但即使从远程发出 Pull,localValues 仍显示 0 个条目。如何让同步表与我的远程表匹配?

【问题讨论】:

    标签: c# sqlite azure xamarin azure-mobile-services


    【解决方案1】:

    奇怪的是,您没有收到任何异常,但您似乎正在创建两个与本地商店的连接。您应该没有有新 SQLiteConnection 的行,只有创建 MobileServiceSQLiteStore 的行。

    这里有一个指导如何设置的教程:https://azure.microsoft.com/en-us/documentation/articles/mobile-services-xamarin-ios-get-started-offline-data/

    我还建议您将 DelegatingHandler 添加到您的 MobileServiceClient 以记录所有请求和响应。然后你可以确切地看到出了什么问题。这是一个示例,它显示了这一点,还包括 SQLite 存储的日志扩展,因此您可以准确地看到本地发生的情况:https://github.com/paulbatum/FieldEngineerLite/blob/master/FieldEngineerLite.Client/FieldEngineerLite/Helpers/LoggingHelpers.cs

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-10-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-26
      • 1970-01-01
      • 2015-12-10
      • 1970-01-01
      相关资源
      最近更新 更多