Wcf 实体框架:附件修改失败/混淆:)

Wcf 实体框架:附件修改失败/混淆:),wcf,entity-framework,ria,Wcf,Entity Framework,Ria,好的。。。我试过谷歌,但点击率不高。我不想滥用,但这是最好的提问地点之一,EF也没有很好的记录 My失败,因为GetOriginal()在UpdateCmsProductCategory中返回null。我假设这意味着currentCmsProductCategory不在变更集中。好啊如何将其放入变更集中 这是顺序 我在Wcf上向下拉了一个CmsProductCategory。 我会做出改变。 我调用Wcf更新方法 public void UpdateProductCategory(CmsProd

好的。。。我试过谷歌,但点击率不高。我不想滥用,但这是最好的提问地点之一,EF也没有很好的记录

My失败,因为GetOriginal()在UpdateCmsProductCategory中返回null。我假设这意味着currentCmsProductCategory不在变更集中。好啊如何将其放入变更集中

这是顺序

我在Wcf上向下拉了一个CmsProductCategory。 我会做出改变。 我调用Wcf更新方法

public void UpdateProductCategory(CmsProductCategory category)
{
    domainservice.UpdateCmsProductCategory(category);
}
它调用域服务方法

public virtual void UpdateCmsProductCategory(CmsProductCategory currentCmsProductCategory)
{
    this.Context.AttachAsModified(currentCmsProductCategory, 
        this.ChangeSet.GetOriginal(currentCmsProductCategory));
}
这应该行得通——但不,当GetOriginal()失败时,它对我来说是个例外。我觉得在代码修改它和我将它传递给Wcf之间缺少了一步

有什么好的文档提示/指针吗


谢谢

您的问题可能是您失去了“上下文”

当您调用更新“this.Context”时,它与您从中读取的内容不同

WCF有“每次呼叫”和“每次会话”的概念。“每次调用”是默认值,因此您将获得域服务的新实例。您可以使用每个会话解决它

请查看此链接:

还可以尝试编写一个测试,以检查您所做的工作是否正常,而无需通过wcf传输数据