Skip to content

Instantly share code, notes, and snippets.

@facilita-tecnologia
Last active December 16, 2019 18:48
Show Gist options
  • Save facilita-tecnologia/42bc40f5cdcacd6c4ab935fe7e071671 to your computer and use it in GitHub Desktop.
Save facilita-tecnologia/42bc40f5cdcacd6c4ab935fe7e071671 to your computer and use it in GitHub Desktop.
update com entity framework
// Localizo o objeto no vanco de dados
var Objeto = context.Set<Identificadores>().FirstOrDefault(u => u.EmpresaId == EmpresaId);
// Faço as modanças que desejo fazer
Objeto.Contador = 1323;
// Atacho
context.Set<Identificadores>().Attach(Objeto);
// Inforço os campos que foram alterados
var entry = context.Entry(_Identificadores);
entry.Property(ae => ae.Contador).IsModified = true;
Por Fim arocho as mudanças
context.SaveChanges();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment