DataContext.ChangeConflicts property

Gets a collection of objects that represent discrepancies between the current client value and the current database value of a field in a list item.

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

public ChangeConflictCollection ChangeConflicts { get; internal set; }

Property value

Type: Microsoft.SharePoint.Linq.ChangeConflictCollection
A ChangeConflictCollection each of whose members represents a discrepancy.

At least one member of the property also represents a concurrency conflict that was detected when SubmitChanges() was last called. ChangeConflicts is not populated unless there was at least one concurrency conflict: a discrepancy between the current database value of the field and the value it had when it was last retrieved by the current process. If a conflict is found, SubmitChanges() also populates ChangeConflicts with objects that represent any discrepancy between the current client value and the current database value.

Typically, your code will catch a ChangeConflictException and resolve the discrepancies in ChangeConflicts in the catch (Catch in Visual Basic) block.

The following is an example of how the ChangeConflicts property is used in a catch block.


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

Show: