【问题标题】:Update on TableController in Azure Mobile Services failsAzure 移动服务中的 TableController 更新失败
【发布时间】:2014-09-24 12:59:38
【问题描述】:

当我在 tablecontroller 上执行 Patch (updateasync) 时,我收到以下错误:

iisexpress.exe Error: 0 : Message='The client is attempting to use optimistic concurrency in
connection with updates and inserts but the current 'SimpleMappedEntityDomainManager`2' 
implementation does not set the original version required to support this. Please implement the 
method 'SetOriginalVersion' and provide the original value.', 
Id=00000000-0000-0000-5d00-0080000000ff, Category='App.Controllers.Tables'

我正在使用 MappedEntityDomainManager,因为我已经连接了一个预先存在的数据库。

查找和插入一切正常。

【问题讨论】:

  • 你能发布你的模型和你的 DTO 的代码(相互映射的类型)吗?

标签: azure-mobile-services


【解决方案1】:

尝试使用以下方法更新您的 SimpleMappedEntityDomainManager<TDTO, TModel> 实现:

protected override void SetOriginalVersion(TModel model, byte[] version)
{
    this.context.Entry(model).OriginalValues["Version"] = version;
}

其中"Version" 是模型类中存储项目版本的属性名称(通常为timestamp 类型)

如果您的数据库中没有任何存储版本的属性(映射到传出 DTO 中的 Version__version 属性),则可以有一个空覆盖:

protected override void SetOriginalVersion(TModel model, byte[] version)
{
}

我找不到有关此功能的任何文档,因此我会将此问题转发给产品团队以进行更正。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多