1
I’m trying to delete an object using the Repository Pattern, but the problem is that when calling the method for removal nothing happens, nor throws exception.
Financeirocontroller.Cs:
[HttpPost]
public ActionResult DeleteConfirmed(int id)
{
var financa = _financeiroApp.ObterFinanca(id); // Aqui retorna o objeto sem nenhuma exceção.
_financeiroApp.Remover(financa);
return RedirectToAction("Index");
}
Repositorybase.Cs:
public void Remover(T obj)
{
banco.Set<T>().Remove(obj); // Não remove, mas também não lança nenhuma exceção.
banco.SaveChanges();
}
I can not understand, because when obtaining the object it is within the context and, therefore, should be removed without any problem.
Ever tried to give a
contexto.SaveChanges();
after removing the object?– DiegoAugusto
I tried yes Diego, I forgot to put here. I already edited.
– Raphael
can show how your Repositorybase Class is declared ?
– DiegoAugusto