I have a Silverlight 4 project using WCF RIA Services RTM. Most of the RIA functionality is working, but I'm having a problem with concurrency checking. The server is correctly checking concurrency and passing a DomainOperationException to the DomainDataSource.SubmittedChanges event. I'm handling that even and enumerating the EntitiesInError. I then call a Resolve on the EntityConflict. This seems to be updating the "old values" for the entities so I can then resubmit them, but the client's changes are preserved in the entity. I would rather wipe out the client's changes and make them re-do them, or maybe eventually show them what changed and let them choose which to keep. Below is a code sample of what I have so far. I found this post: http://sklementiev.blogspot.com/2010/03/wcf-ria-and-concurrency.html but it doesn't seem to work with the RIA Services RTM. Thanks.
Code Sample:
Private Sub dds_SubmittedChanges(ByVal sender As Object, ByVal e As System.Windows.Controls.SubmittedChangesEventArgs)
If e.HasError Then
If TypeOf e.Error Is DomainOperationException Then
handleDomainOperationException(sender, e, "myType")
End If
End If
End Sub
Private Sub handleDomainOperationException(ByVal sender As Object, ByVal e As SubmittedChangesEventArgs, ByVal entityType As String)
Dim dds As DomainDataSource = DirectCast(sender, DomainDataSource)
Select Case DirectCast(e.Error, DomainOperationException).Status
Case OperationErrorStatus.Conflicts
ErrorWindow.CreateNew(String.Format("Another user updated this {0} between the time that you viewed it and when you submitted your changes. Your changes have been reverted. Please make your changes again and re-submit.", entityType))
For Each ent In e.EntitiesInError
If Not ent.EntityConflict.IsDeleted Then
'tried this, doesn't overwrite changes, just updates old fields
ent.EntityConflict.Resolve()
Else
Throw New Exception("This entity has already been deleted.")
End If
Next
e.MarkErrorAsHandled()
Case OperationErrorStatus.ValidationFailed
ErrorWindow.CreateNew("Data validation failed")
End Select
End Sub