Android Azure 移动服务离线同步软删除

标签 android .net azure soft-delete

我已经实现了一个支持 Azure 移动服务和离线同步的 Android 应用程序。我已经用两种不同的设备对其进行了测试。我在第一台设备上执行删除操作(软删除)并且工作正常。然后我让它同步,检查服务器端记录,“已删除”列已标记为“true”。但我似乎无法让第二台平板电脑同步以反射(reflect)新的更改,即不显示已删除的记录。

为了启用软删除,我已将enableSoftDelete: true添加到Azure上应用服务的表 Controller 中。我没有在删除过程方面触及我的应用程序,但以下是典型的删除:

    Save save = getSave(SaveID);
try {
            mtblSave.delete(save);
            return true;

        } catch (Exception exception) {
            exception.printStackTrace();
            return false;
        }

我正在将 .NET 后端与 Azure SQL Server 结合使用。

有什么想法吗?

提前致谢

最佳答案

But I cannot seem to get the second tablet to sync to reflect the new changes i.e. do not display the deleted record.

Using soft delete in Mobile Services提及如下:

When using the Offline data Sync for Mobile Services feature, the client SDK automatically queries for deleted records and removes them from the local database. Without soft delete enabled, you need to write additional code on the backend so that the client SDK knows which records to remove from the local store. Otherwise, the client local store and backend will be inconsistent with regard to these deleted records and the client method PurgeAsync() must be called to clear the local store.

我以为你可以利用fiddler在处理拉操作时捕获网络痕迹。另外,您可以添加 includeDeleted为了更好地理解此功能,您可以按如下方式构造拉取数据的查询时使用方法。

var pullQuery = mClient.getTable(ToDoItem.class).where().field("complete").eq(false).includeDeleted();
mToDoTable.pull(mPullQuery).get();

此外,有关在移动服务中使用离线数据同步的更多详细信息,您可以引用here .

更新:

查询参数是用于过滤结果的可选查询。

How offline synchronization works提到增量同步:

If you use a non-null queryId, the Azure Mobile SDK performs an incremental sync. Each time a pull operation returns a set of results, the latest updatedAt timestamp from that result set is stored in the SDK local system tables. Subsequent pull operations retrieve only records after that timestamp.

The query name can be any string you choose, but it must be unique for each logical query in your app. Otherwise, different pull operations could overwrite the same incremental sync timestamp and your queries can return incorrect results.

可以引用这个answer并解决您的问题。

关于Android Azure 移动服务离线同步软删除,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45719273/

相关文章:

java - 从 RecyclerView 中的 ViewHolder 中删除小部件

android - 解锁设备时如何自动运行应用程序

c# - 有什么简单的方法可以连接两个 BitArray (C# .NET)?

azure - 无法引用 Azure Functions 中的 Polly 或其他包

java - 如何在 Android 中读取文件上传的服务器响应(JSON)?

.net - 使用 VS 2010 进行单元测试的教程

.net - VB.NET中Integer和Int32有什么区别?

angular - 无法加载资源 : the server $%7Bthis. originUrl%7D/.auth/me:1 状态 404(未找到)

c# - azure应用程序服务中的Google应用程序凭据(aspnet core web api)

java - 无法从静态上下文中引用非静态方法 'getSharedPreferences (java.lang.String, int)'