Compartilhar via


MemberChangeConflict.Resolve Method (RefreshMode)

Resolves the discrepancy using the specified refresh mode.

Namespace:  Microsoft.SharePoint.Linq
Assembly:  Microsoft.SharePoint.Linq (in Microsoft.SharePoint.Linq.dll)

Syntax

'Declaration
Public Sub Resolve ( _
    refreshMode As RefreshMode _
)
'Usage
Dim instance As MemberChangeConflict
Dim refreshMode As RefreshMode

instance.Resolve(refreshMode)
public void Resolve(
    RefreshMode refreshMode
)

Parameters

Remarks

Resolve(RefreshMode) resolves the discrepancy between the client value (that is, the value in the current process on the front-end Web server) and the database value by assigning to the client version a value that is persisted to the database on the next call of SubmitChanges. The refreshMode parameter determines what principle it uses to decide what value to assign.

Examples

The following example shows how the Resolve(RefreshMode) method is used in a catch block that handles a ChangeConflictException:

foreach (TeamMember teamMember in teamSite.TeamMembers)
{
    teamMember.TopTask = “Fiscal Planning”;
}

try 
{
    teamSite.SubmitChanges(ConflictMode.ContinueOnConflict);
}
catch (ChangeConflictException e) 
{
    foreach (ObjectChangeConflict changedListItem in teamSite.ChangeConflicts)
    {
        // If another user has changed properties of a non-manager,
        // leave that other user’s changes, except for the TopTask field.
        if (((TeamMember)changedListItem.Object).IsManager = false)
        {        
             foreach (MemberChangeConflict changedField in changedListItem.MemberConflicts)
            {
                if (changedField.Member.Name == “TopTask”)
                {
                    changedField.Resolve(RefreshMode.KeepCurrentValues);
                }
                else
                {
                    changedField.Resolve(RefreshMode.OverwriteCurrentValues);
                }
            }
        }
        // But if another user has changed properties of a manager, let this
        // process’s changes override the other user’s changes.
        else
        {
            changedListItem.Resolve(RefreshMode.KeepCurrentValues);
        }    
    }

    teamSite.SubmitChanges();
} // end catch
For Each teamMember As TeamMember In teamSite.TeamMembers
    teamMember.TopTask = "Fiscal Planning"
Next teamMember

Try
    teamSite.SubmitChanges(ConflictMode.ContinueOnConflict)
Catch e As ChangeConflictException
    For Each changedListItem As ObjectChangeConflict In teamSite.ChangeConflicts
        ' If another user has changed properties of a non-manager,
        ' leave that other user’s changes, except for the TopTask field.
        If Not (CType(changedListItem.Object, TeamMember)).IsManager Then
             For Each changedField As MemberChangeConflict In changedListItem.MemberConflicts
                If changedField.Member.Name = "TopTask" Then
                    changedField. Resolve(RefreshMode.KeepCurrentValues)
                Else
                    changedField. Resolve(RefreshMode.OverwriteCurrentValues)
                End If
             Next changedField
        ' But if another user has changed properties of a manager, let this
        ' process’s changes override the other user’s changes.
        Else
            changedListItem.Resolve(RefreshMode.KeepCurrentValues)
        End If
    Next changedListItem

    teamSite.SubmitChanges()
End Try ' end catch

See Also

Reference

MemberChangeConflict Class

MemberChangeConflict Members

Resolve Overload

Microsoft.SharePoint.Linq Namespace