다음을 통해 공유


DataContext.ChangeConflicts 속성

정의

SubmitChanges()를 호출했을 때 동시성 충돌이 발생한 개체의 컬렉션을 가져옵니다.

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

속성 값

동시성 충돌이 발생한 개체의 컬렉션입니다.

예제

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

설명

다음 예제에서는 컬렉션을 반복하여 충돌 정보를 검색하는 방법을 보여줍니다.

적용 대상