The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
How to: Retrieve Member Conflict Information (LINQ to SQL)
.NET Framework 3.5
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.
Note: |
|---|
Include System.Reflection in order to provide Member information. |
' Add 'Imports System.Reflection' for this section. 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 As Object = occ.Object Console.WriteLine("Table name: " & metatable.TableName) Console.Write("Customer ID: ") Console.WriteLine(entityInConflict.CustomerID) For Each mcc As MemberChangeConflict In occ.MemberConflicts Dim currVal = mcc.CurrentValue Dim origVal = mcc.OriginalValue Dim databaseVal = mcc.DatabaseValue Dim mi As MemberInfo = mcc.Member Console.WriteLine("Member: " & mi.Name) Console.WriteLine("current value: " & currVal) Console.WriteLine("original value: " & origVal) Console.WriteLine("database value: " & databaseVal) Console.ReadLine() Next Next End Try
Community Additions
Show:
Note: