共用方式為


ObjectChangeConflict.Resolve 方法

定義

解決成員衝突。

多載

Resolve()

藉由保留目前值以及重設基準原始值以符合較新的資料庫值,解決成員衝突。

Resolve(RefreshMode)

使用指定的 RefreshMode,解決成員衝突。

Resolve(RefreshMode, Boolean)

藉由保留目前值以及重設基準原始值來解決成員衝突。

Resolve()

藉由保留目前值以及重設基準原始值以符合較新的資料庫值,解決成員衝突。

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

適用於

Resolve(RefreshMode)

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

參數

refreshMode
RefreshMode

來自 RefreshMode 的適當選項。

範例

下列範例會以資料庫中的值覆寫目前的值。

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

下列範例示範如何將原始值與從資料庫擷取的值交換。 未修改目前的值。

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

下列範例會保留已變更的目前值,但會以資料庫值更新其他值。

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來產生哪些結果。

適用於

Resolve(RefreshMode, Boolean)

藉由保留目前值以及重設基準原始值來解決成員衝突。

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)

參數

refreshMode
RefreshMode

來自 RefreshMode 的適當選項。

autoResolveDeletes
Boolean

當為 true 時,則自動解決因已修改物件不再位於資料庫中所造成的衝突。

適用於