RefreshMode RefreshMode RefreshMode RefreshMode Enum

Definição

Define como o método Refresh trata conflitos de simultaneidade otimista.Defines how the Refresh method handles optimistic concurrency conflicts.

public enum class RefreshMode
public enum RefreshMode
type RefreshMode = 
Public Enum RefreshMode
Herança

Campos

KeepChanges KeepChanges KeepChanges KeepChanges 1

Força o método Refresh para manter o valor atual que foi alterado, mas atualiza os outros valores com os valores do banco de dados.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

Força o método Refresh a trocar o valor original pelos valores recuperados do banco de dados.Forces the Refresh method to swap the original value with the values retrieved from the database. Nenhum valor atual é modificado.No current value is modified.

OverwriteCurrentValues OverwriteCurrentValues OverwriteCurrentValues OverwriteCurrentValues 2

Força o método Refresh a substituir todos os valores atuais pelos valores do banco de dados.Forces the Refresh method to override all the current values with the values from the database.

Exemplos

O exemplo a seguir substitui os valores atuais por valores do banco de dados.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

O exemplo a seguir mostra como trocar o valor original pelos valores recuperados do banco de dados.The following example shows how to swap the original value with the values retrieved from the database. Nenhum valor atual é modificado.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

O exemplo a seguir mantém os valores atuais que foram alterados, mas atualiza os outros valores com valores de banco de dados.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)

Comentários

Essa enumeração se aplica a Refresh todas as sobrecargas.This enumeration applies to all Refresh overloads.

Aplica-se a