LinqConnect Documentation
Devart.Data.Linq Namespace / DataContext Class / ChangeConflicts Property
Example

In This Topic
    ChangeConflicts Property
    In This Topic
    Returns a collection of objects that caused concurrency conflicts when SubmitChanges was called.
    Syntax
    'Declaration
     
    Public ReadOnly Property ChangeConflicts As ChangeConflictCollection
    public ChangeConflictCollection ChangeConflicts {get;}

    Property Value

    A collection of objects that caused concurrency conflicts when SubmitChanges was called.
    Remarks
    Can be used only if the SubmitChanges(ConflictMode) with ContinueOnConflict as the failureMode was called.
    Example
    The following example shows how the collection can be iterated over to retrieve conflict information.

    Optimistic Concurrency: Overview

    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
    Requirements

    Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

    See Also