ObjectChangeConflict.Resolve ObjectChangeConflict.Resolve ObjectChangeConflict.Resolve ObjectChangeConflict.Resolve Method

定義

解決成員衝突。Resolves member conflicts.

多載

Resolve() Resolve() Resolve() Resolve()

藉由保留目前值以及重設基準原始值以符合較新的資料庫值,解決成員衝突。Resolves member conflicts by keeping current values and resetting the baseline original values to match the more recent database values.

Resolve(RefreshMode) Resolve(RefreshMode) Resolve(RefreshMode)

使用指定的 RefreshMode,解決成員衝突。Resolves member conflicts by using the specified RefreshMode.

Resolve(RefreshMode, Boolean) Resolve(RefreshMode, Boolean) Resolve(RefreshMode, Boolean)

藉由保留目前值以及重設基準原始值來解決成員衝突。Resolve member conflicts keeping current values and resetting the baseline original values.

Resolve() Resolve() Resolve() 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 ()

Resolve(RefreshMode) Resolve(RefreshMode) Resolve(RefreshMode)

使用指定的 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

參數

refreshMode
RefreshMode RefreshMode RefreshMode RefreshMode

來自 RefreshMode 的適當選項。The appropriate option from RefreshMode.

範例

下列範例會使用資料庫中的值來覆寫目前的值。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)

備註

下列範例顯示使用的各種值RefreshMode所產生的結果。The following examples show what results are produced by using the various values for RefreshMode.

Resolve(RefreshMode, Boolean) Resolve(RefreshMode, Boolean) 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

參數

refreshMode
RefreshMode RefreshMode RefreshMode RefreshMode

來自 RefreshMode 的適當選項。The appropriate option from RefreshMode.

autoResolveDeletes
Boolean Boolean Boolean Boolean

當為 true 時,則自動解決因已修改物件不再位於資料庫中所造成的衝突。When true, automatically resolves conflicts resulting from a modified object that is no longer in the database.

適用於