RefreshMode RefreshMode RefreshMode RefreshMode Enum

Definición

Define cómo controla el método Refresh los conflictos de simultaneidad optimista.Defines how the Refresh method handles optimistic concurrency conflicts.

public enum class RefreshMode
public enum RefreshMode
type RefreshMode = 
Public Enum RefreshMode
Herencia

Campos

KeepChanges KeepChanges KeepChanges KeepChanges 1

Obliga al método Refresh a mantener el valor actual que se ha cambiado, pero actualiza el resto de los valores con los valores de la base de datos.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

Obliga al método Refresh a intercambiar el valor original con los valores recuperados de la base de datos.Forces the Refresh method to swap the original value with the values retrieved from the database. No se modifica ningún valor actual.No current value is modified.

OverwriteCurrentValues OverwriteCurrentValues OverwriteCurrentValues OverwriteCurrentValues 2

Obliga al método Refresh a invalidar todos los valores actuales con los valores de la base de datos.Forces the Refresh method to override all the current values with the values from the database.

Ejemplos

En el ejemplo siguiente, se sobrescribe los valores actuales con los valores de la base de datos.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

El ejemplo siguiente muestra cómo intercambiar el valor original con los valores recuperados de la base de datos.The following example shows how to swap the original value with the values retrieved from the database. No se modifica ningún valor actual.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

El ejemplo siguiente mantiene los valores actuales que se han cambiado, pero actualizan los demás valores con los valores de la base de datos.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)

Comentarios

Esta enumeración se aplica a todos los Refresh sobrecargas.This enumeration applies to all Refresh overloads.

Se aplica a