DataContext.ChangeConflicts Property

 

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

Namespace:   System.Data.Linq
Assembly:  System.Data.Linq (in System.Data.Linq.dll)

public ChangeConflictCollection ChangeConflicts { get; }

Property Value

Type: System.Data.Linq.ChangeConflictCollection

A collection of objects that caused concurrency conflicts.

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

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();
    }
}

.NET Framework
Available since 3.5
Windows Phone Silverlight
Available since 7.1
Return to top
Show: