Share via


ChangeConflictException Class

Represents the exception that is thrown when an update fails because database values have been updated since the client last read them.

Inheritance Hierarchy

System.Object
  System.Exception
    Microsoft.SharePoint.Linq.ChangeConflictException

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

Syntax

'Declaration
<SerializableAttribute> _
Public Class ChangeConflictException _
    Inherits Exception
'Usage
Dim instance As ChangeConflictException
[SerializableAttribute]
public class ChangeConflictException : Exception

Remarks

This exception is thrown by SubmitChanges() when it detects a concurrency conflict. Your code should always catch and resolve the discrepancies. For more information about resolution of conflicts, see How to: Write to Lists Using LINQ to SharePoint.

Examples

The following is a simple example of catching the exception and resolving the discrepancies.

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

try 
{
    teamSite.SubmitChanges();
}
catch (ChangeConflictException e) 
{
    teamSite.ChangeConflicts.ResolveAll();
    teamSite.SubmitChanges();
}
For Each teamMember As TeamMember In teamSite.TeamMembers
    teamMember.TopTask = "Fiscal Planning"
Next teamMember

Try
    teamSite.SubmitChanges()
Catch e As ChangeConflictException
    teamSite.ChangeConflicts.ResolveAll()
    teamSite.SubmitChanges()
End Try

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

ChangeConflictException Members

Microsoft.SharePoint.Linq Namespace