RefreshMode RefreshMode RefreshMode RefreshMode Enum

Definizione

Definisce le modalità con le quali il metodo Refresh gestisce i conflitti di concorrenza ottimistica.Defines how the Refresh method handles optimistic concurrency conflicts.

public enum class RefreshMode
public enum RefreshMode
type RefreshMode = 
Public Enum RefreshMode
Ereditarietà

Campi

KeepChanges KeepChanges KeepChanges KeepChanges 1

Impone al metodo Refresh di mantenere il valore corrente che è stato modificato, ma aggiorna gli altri valori con i valori del database.Forces the Refresh method to keep the current value that has been changed, but updates the other values with the database values.

KeepCurrentValues KeepCurrentValues KeepCurrentValues KeepCurrentValues 0

Impone al metodo Refresh di scambiare il valore originale con i valori recuperati dal database.Forces the Refresh method to swap the original value with the values retrieved from the database. Non viene modificato alcun valore corrente.No current value is modified.

OverwriteCurrentValues OverwriteCurrentValues OverwriteCurrentValues OverwriteCurrentValues 2

Impone al metodo Refresh di eseguire l'override di tutti i valori correnti con i valori recuperati dal database.Forces the Refresh method to override all the current values with the values from the database.

Esempi

Nell'esempio seguente vengono sovrascritti i valori correnti con i valori del database.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

Nell'esempio seguente viene illustrato come scambiare il valore originale con i valori recuperati dal database.The following example shows how to swap the original value with the values retrieved from the database. Non viene modificato alcun valore corrente.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

Nell'esempio seguente vengono mantenuti i valori correnti che sono stati modificati, ma vengono aggiornati gli altri valori con i valori del database.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)

Commenti

Questa enumerazione si applica a Refresh tutti gli overload.This enumeration applies to all Refresh overloads.

Si applica a