Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

DataContext.ChangeConflicts Property

Definition

Namespace:
System.Data.Linq
Assembly:
System.Data.Linq.dll

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Gets a collection of objects that caused concurrency conflicts when SubmitChanges() was called.

public:
 property System::Data::Linq::ChangeConflictCollection ^ ChangeConflicts { System::Data::Linq::ChangeConflictCollection ^ get(); };
public System.Data.Linq.ChangeConflictCollection ChangeConflicts { get; }
member this.ChangeConflicts : System.Data.Linq.ChangeConflictCollection
Public ReadOnly Property ChangeConflicts As ChangeConflictCollection

Property Value

A collection of objects that caused concurrency conflicts.

Examples

Northwnd db = new Northwnd("...");

try
{
 db.SubmitChanges(ConflictMode.ContinueOnConflict);
}

catch (ChangeConflictException e)
{
 Console.WriteLine("Optimistic concurrency error.");
 Console.WriteLine(e.Message);
 foreach (ObjectChangeConflict occ in db.ChangeConflicts)
 {
 MetaTable metatable = db.Mapping.GetTable(occ.Object.GetType());
 Customer entityInConflict = (Customer)occ.Object;
 Console.WriteLine("Table name: {0}", metatable.TableName);
 Console.Write("Customer ID: ");
 Console.WriteLine(entityInConflict.CustomerID);
 Console.ReadLine();
 }
}
Dim db As New Northwnd("...")

Try
 db.SubmitChanges(ConflictMode.ContinueOnConflict)

Catch ex As ChangeConflictException
 Console.WriteLine("Optimistic concurrency error.")
 Console.WriteLine(ex.Message)
 For Each occ As ObjectChangeConflict In db.ChangeConflicts
 Dim metatable As MetaTable = db.Mapping.GetTable(occ.Object.GetType())
 Dim entityInConflict = occ.Object

 Console.WriteLine("Table name: " & metatable.TableName)
 Console.Write("Customer ID: ")
 Console.WriteLine(entityInConflict.CustomerID)
 Console.ReadLine()
 Next
End Try

Remarks

The following example shows how the collection can be iterated over to retrieve conflict information.

Applies to


Feedback

Was this page helpful?