Silverlight 4 DomainService - EntitiesInError - EntityConflict - PropertyNames 抛出 InvalidOperationException

发布于 2024-09-18 10:03:26 字数 1044 浏览 10 评论 0原文

遵循 Silverlight 4 RIA 中新的 DomainService 的介绍教程,我遇到了意外的异常。当我执行更新时,属性 EntitiesInError[index].EntityConflict.PropertyNames 抛出以下异常:

InvalidOperationException:PropertyNames 不可用于删除冲突。

执行的服务方法:

public void UpdateSr_Supplier(sr_Supplier currentsr_Supplier)
{
    // UPDATE the existing sr_Supplier
    this.ObjectContext.sr_Supplier.AttachAsModified(currentsr_Supplier, this.ChangeSet.GetOriginal(currentsr_Supplier));
}

从回答 这个线程我认为我应该将支持Silverlight的服务与自定义服务对象(DataContractDataMember)一起使用,然后分配这些自定义服务对象的值到实际的服务器对象(从数据库模型生成,可以是 Linq to Sql 或实体数据模型),并在 DataContext 上手动调用 SubmitChanges()

Following an introductory tutorial for the new DomainService in Silverlight 4 RIA, I got an unexpected exception. When I perform an update the property EntitiesInError[index].EntityConflict.PropertyNames throws the following exception:

InvalidOperationException: PropertyNames are not available for delete conflicts.

Service method executed:

public void UpdateSr_Supplier(sr_Supplier currentsr_Supplier)
{
    // UPDATE the existing sr_Supplier
    this.ObjectContext.sr_Supplier.AttachAsModified(currentsr_Supplier, this.ChangeSet.GetOriginal(currentsr_Supplier));
}

From the answer on this thread I gather that I should rather use Silverlight-enabled services with custom service objects (DataContract and DataMember), then assign the values of these custom service objects to the actual server objects (generated from the DB model, be that Linq to Sql or the Entity Data Model), and manually call SubmitChanges() on the DataContext.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

赠佳期 2024-09-25 10:03:26

如果您正在处理的错误是删除冲突,PropertyNames 将引发异常,这是正常的。您应该寻找底层数据库错误,这可能是忽略设置非空值或主键违规等。

PropertyNames will throw an exception if the error you're dealing with is a deletion conflict, this is normal. You should be looking for the underlying database error, which may be neglecting to set a non-null value or a primary key violation, etc.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文