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.
精彩评论