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 the Content Databases 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