简体   繁体   English

如果删除数据,Azure App Service移动应用程序数据库同步失败

[英]Azure App Service Mobile App database synchronization failes if data is deleted

I'm currently facing such a problem: I'm building an app using Xamarin and Azure App Service Mobile App as a cloud back-end. 我目前面临这样的问题:我正在使用Xamarin和Azure App Service移动应用程序作为云后端构建应用程序。 The thing is that if I delete some data from the corresponding table in DB hosted in Azure the next PullAsync call on mobile device fails because it tries to request the deleted record. 事实是,如果我从Azure托管的数据库中的对应表中删除一些数据,则移动设备上的下一个PullAsync调用将失败,因为它尝试请求删除的记录。 Is there any way to synchronize the deletion of the records which happens first in Azure DB and then is pulled to the device? 有什么方法可以同步删除记录,该删除首先在Azure DB中发生,然后又被拉到设备上?

The other way works smoothly: if I delete the record from the device, the corresponding record is deleted in Azure DB. 另一种方法可以正常工作:如果我从设备中删除记录,则相应的记录将在Azure DB中删除。

You have to use soft delete by enabling is on your server for each TableController where you require it. 您必须通过在服务器上为需要的每个TableController启用来使用软删除。 Example here for a TodoItem TableController . 例如这里进行TodoItem TableController

protected override void Initialize(HttpControllerContext controllerContext)
{
    base.Initialize(controllerContext);
    MobileServiceContext context = new MobileServiceContext();
    DomainManager = new EntityDomainManager<TodoItem>(context, Request, enableSoftDelete: true);
}

More info here . 更多信息在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM