WCF RIA Services RTM을 사용하는 Silverlight 4 프로젝트가 있습니다. 대부분의 RIA 기능이 작동하지만 동시성 검사에 문제가 있습니다. 서버가 동시성을 올바르게 확인하고 DomainOperationException을 DomainDataSource.SubmittedChanges 이벤트로 전달합니다. 나는 이것을 처리하고 EntitiesInError를 열거한다. 그런 다음 EntityConflict에 대한 Resolve를 호출합니다. 이것은 엔터티에 대한 "이전 값"을 업데이트하는 것으로 보이므로 다시 제출할 수 있지만 클라이언트의 변경 사항은 엔터티에 보존됩니다. 차라리 고객의 변경 사항을 없애고 다시 변경하거나 결국 변경된 내용을 표시하고 유지할 항목을 선택하도록 할 것입니다. 아래는 내가 지금까지 가지고있는 코드 샘플이다. 나는이 게시물을 발견 : http://sklementiev.blogspot.com/2010/03/wcf-ria-and-concurrency.html하지만 그것은 RIA 서비스 RTM과 함께 작동하지 않는 것. 감사.WCF RIA 서비스가있는 Silverlight 클라이언트에서 동시성 오류 해결
코드 샘플 :
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