Edit

Share via


MemberChangeConflict.Resolve Method

Definition

Resolves member conflicts by keeping current values and resetting the baseline original values to match the more recent database values.

Overloads

Resolve(RefreshMode)

Uses a RefreshMode parameter to automatically specify the value to set as the current value for the member in conflict.

Resolve(Object)

Specifies the value to set as the current value for the member in conflict.

Resolve(RefreshMode)

Uses a RefreshMode parameter to automatically specify the value to set as the current value for the member in conflict.

public:
 void Resolve(System::Data::Linq::RefreshMode refreshMode);
public void Resolve (System.Data.Linq.RefreshMode refreshMode);
member this.Resolve : System.Data.Linq.RefreshMode -> unit
Public Sub Resolve (refreshMode As RefreshMode)

Parameters

refreshMode
RefreshMode

See RefreshMode.

Examples

The following example overwrites current values with values from the database.

Northwnd db = new Northwnd("...");
try
{
    db.SubmitChanges(ConflictMode.ContinueOnConflict);
}

catch (ChangeConflictException e)
{
    Console.WriteLine(e.Message);
    foreach (ObjectChangeConflict occ in db.ChangeConflicts)
    {
        // All database values overwrite current values.
        occ.Resolve(RefreshMode.OverwriteCurrentValues);
    }
}
Dim db As New Northwnd("...")

Try
    db.SubmitChanges(ConflictMode.ContinueOnConflict)

Catch ex As ChangeConflictException
    Console.WriteLine(ex.Message)

    For Each occ As ObjectChangeConflict In db.ChangeConflicts
        ' All database values overwrite current values.
        occ.Resolve(Data.Linq.RefreshMode.OverwriteCurrentValues)
    Next

End Try

The following example shows how to swap the original value with the values retrieved from the database. No current value is modified.

try
{
    db.SubmitChanges(ConflictMode.ContinueOnConflict);
}

catch (ChangeConflictException e)
{
    Console.WriteLine(e.Message);
    foreach (ObjectChangeConflict occ in db.ChangeConflicts)
    {
        //No database values are merged into current.
        occ.Resolve(RefreshMode.KeepCurrentValues);
    }
}
Try
    db.SubmitChanges(ConflictMode.ContinueOnConflict)

Catch ex As ChangeConflictException
    Console.WriteLine(ex.Message)

    For Each occ As ObjectChangeConflict In db.ChangeConflicts
        ' No database values are merged into current.
        occ.Resolve(Data.Linq.RefreshMode.KeepCurrentValues)
    Next

End Try

The following example keeps the current values that have been changed, but updates the other values with database values.

try
{
    db.SubmitChanges(ConflictMode.ContinueOnConflict);
}

catch (ChangeConflictException e)
{
    Console.WriteLine(e.Message);
    // Automerge database values for members that client
    // has not modified.
    foreach (ObjectChangeConflict occ in db.ChangeConflicts)
    {
        occ.Resolve(RefreshMode.KeepChanges);
    }
}

// Submit succeeds on second try.
db.SubmitChanges(ConflictMode.FailOnFirstConflict);
Try
    db.SubmitChanges(ConflictMode.ContinueOnConflict)

Catch ex As ChangeConflictException
    Console.WriteLine(ex.Message)

    For Each occ As ObjectChangeConflict In db.ChangeConflicts
        ' Automerge database values into current for members
        ' that client has not modified.
        occ.Resolve(Data.Linq.RefreshMode.KeepChanges)
    Next

End Try

' Submit succeeds on second try.
db.SubmitChanges(ConflictMode.FailOnFirstConflict)

Remarks

The following examples show what results are produced by using the various values for RefreshMode.

Applies to

Resolve(Object)

Specifies the value to set as the current value for the member in conflict.

public:
 void Resolve(System::Object ^ value);
public void Resolve (object value);
member this.Resolve : obj -> unit
Public Sub Resolve (value As Object)

Parameters

value
Object

The value to set as the current value.

Remarks

The value set here is the value to be used in a subsequent SubmitChanges operation.

Applies to