开发者

Silverlight 4 DomainService - EntitiesInError - EntityConflict - PropertyNames throws InvalidOperationException

开发者 https://www.devze.com 2023-01-14 19:42 出处:网络
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.PropertyNa

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开发者_Go百科 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消