대상 공급자가 변경 단위를 포함하는 변경 내용의 대상 복제본에 변경 내용을 적용하려고 시도했을 때 제약 조건 충돌이 발생했음을 보고합니다.
네임스페이스: Microsoft.Synchronization
어셈블리: microsoft.synchronization.dll의 Microsoft.Synchronization
구문
‘선언
Public Sub RecordConstraintConflictForChangeUnit ( _
changeUnitChange As ChangeUnitChange _
)
‘사용 방법
Dim instance As SaveChangeWithChangeUnitsContext
Dim changeUnitChange As ChangeUnitChange
instance.RecordConstraintConflictForChangeUnit(changeUnitChange)
public void RecordConstraintConflictForChangeUnit (
ChangeUnitChange changeUnitChange
)
public:
void RecordConstraintConflictForChangeUnit (
ChangeUnitChange^ changeUnitChange
)
public void RecordConstraintConflictForChangeUnit (
ChangeUnitChange changeUnitChange
)
public function RecordConstraintConflictForChangeUnit (
changeUnitChange : ChangeUnitChange
)
매개 변수
- changeUnitChange
적용할 변경 단위와 충돌하는 대상 복제본에 대한 변경 단위입니다.
예외
| 예외 형식 | 조건 |
|---|---|
changeUnitChange가 null 참조(Visual Basic에서는 Nothing)입니다. |
|
changeUnitChange가 적용할 변경 내용에 없습니다. |
|
제약 조건 충돌이나 복구할 수 있는 오류가 이미 이 개체에 대해 설정되어 있습니다. |
주의
대상 공급자가 대상 복제본에 변경 내용을 적용하려고 시도하고 변경 내용이 대상 복제본의 제약 조건을 위반할 때 제약 조건 충돌이 발생합니다. 변경 단위의 경우 이는 일반적으로 변경 내용이 대상 복제본의 일부 비즈니스 논리를 위반함을 의미합니다. 비즈니스 논리 충돌의 예로 두 개의 변경 단위 name 및 country를 저장하는 정확성 낮은 복제본과 세 개의 변경 단위 name, state/province 및 country를 저장하는 정확성 높은 복제본이 있다고 가정합니다. 정확성 높은 복제본에는 country 필드에 대해 state/province 필드를 검사하는 비즈니스 논리가 포함되어 있고 검사를 통과하지 못하는 변경 내용은 저장되지 않습니다. 정확성 낮은 복제본은 원본으로 사용되며 country가 "USA"로 설정된 항목을 보냅니다. 대상 공급자가 변경 내용을 정확성 높은 복제본에 적용하려고 시도하지만 정확성 높은 복제본에서는 항목의 state/province 필드에 "British Columbia"가 포함되어 있습니다. 따라서 변경 내용이 비즈니스 논리를 위반하므로 state/province 필드를 나타내는 변경 단위에서 제약 조건 충돌이 발생합니다.
대상 공급자가 이 메서드를 사용하여 제약 조건 충돌을 보고하는 경우 변경 내용 적용자는 지정된 충돌에 대해 응용 프로그램에서 설정한 충돌 해결 동작에 따라 충돌을 해결합니다. 그런 다음 변경 내용 적용자는 대상 공급자가 해결된 충돌을 대상 복제본에 적용할 수 있도록 대상 공급자에 필요한 호출을 디스패치합니다. 자세한 내용은 제약 조건 충돌 검색 및 해결을 참조하십시오.
예제
다음 예제에서는 대상 복제본에서 변경 단위를 업데이트할 수 있는지 여부를 검사합니다. 변경 단위를 업데이트할 수 없으면 제약 조건 충돌이 변경 단위에 대해 기록됩니다.
Case SaveChangeAction.UpdateVersionAndData
If True Then
' Update the item store and metadata store for the specified change unit.
Try
Dim cuData As String = DirectCast(context.ChangeData, String())(cuChange.ChangeUnitId.GetByteId())
If _ContactStore.CanUpdateContact(change.ItemId, cuChange.ChangeUnitId, cuData) Then
_ContactStore.UpdateContactFromSync(change, cuChange, cuData)
Else
context.RecordConstraintConflictForChangeUnit(cuChange)
End If
Catch ex As Exception
Dim errData As New RecoverableErrorData(ex)
context.RecordRecoverableErrorForChangeUnit(cuChange, errData)
End Try
Exit Select
End If
case SaveChangeAction.UpdateVersionAndData:
{
// Update the item store and metadata store for the specified change unit.
try
{
string cuData = ((string[])context.ChangeData)[cuChange.ChangeUnitId.GetByteId()];
if (_ContactStore.CanUpdateContact(change.ItemId, cuChange.ChangeUnitId, cuData))
{
_ContactStore.UpdateContactFromSync(change, cuChange, cuData);
}
else
{
context.RecordConstraintConflictForChangeUnit(cuChange);
}
}
catch (Exception ex)
{
RecoverableErrorData errData = new RecoverableErrorData(ex);
context.RecordRecoverableErrorForChangeUnit(cuChange, errData);
}
break;
}
참고 항목
참조
SaveChangeWithChangeUnitsContext 클래스
SaveChangeWithChangeUnitsContext 멤버
Microsoft.Synchronization 네임스페이스