This documentation is archived and is not being maintained.

How to: Retrieve Member Conflict Information (LINQ to SQL)

You can use the MemberChangeConflict class to retrieve information about individual members in conflict. In this same context you can provide for custom handling of the conflict for any member. For more information, see Optimistic Concurrency Overview (LINQ to SQL).

The following code iterates through the ObjectChangeConflict objects. For each object, it then iterates through the MemberChangeConflict objects.


Include System.Reflection in order to provide Member information.

// Add 'using System.Reflection' for this section.
Northwnd db = new Northwnd("...");


catch (ChangeConflictException e)
    Console.WriteLine("Optimistic concurrency error.");
    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: ");
        foreach (MemberChangeConflict mcc in occ.MemberConflicts)
            object currVal = mcc.CurrentValue;
            object origVal = mcc.OriginalValue;
            object databaseVal = mcc.DatabaseValue;
            MemberInfo mi = mcc.Member;
            Console.WriteLine("Member: {0}", mi.Name);
            Console.WriteLine("current value: {0}", currVal);
            Console.WriteLine("original value: {0}", origVal);
            Console.WriteLine("database value: {0}", databaseVal);