Last active
December 16, 2019 18:48
-
-
Save facilita-tecnologia/42bc40f5cdcacd6c4ab935fe7e071671 to your computer and use it in GitHub Desktop.
update com entity framework
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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