Επεξεργασία

Κοινή χρήση μέσω


ObjectChangeConflict.Resolve Method

Definition

Resolves member conflicts.

Overloads

Resolve()

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

Resolve(RefreshMode)

Resolves member conflicts by using the specified RefreshMode.

Resolve(RefreshMode, Boolean)

Resolve member conflicts keeping current values and resetting the baseline original values.

Resolve()

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

public:
 void Resolve();
public void Resolve ();
member this.Resolve : unit -> unit
Public Sub Resolve ()

Applies to

Resolve(RefreshMode)

Resolves member conflicts by using the specified RefreshMode.

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

The appropriate option from 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(RefreshMode, Boolean)

Resolve member conflicts keeping current values and resetting the baseline original values.

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

Parameters

refreshMode
RefreshMode

The appropriate option from RefreshMode.

autoResolveDeletes
Boolean

When true, automatically resolves conflicts resulting from a modified object that is no longer in the database.

Applies to