I comment quickly: for the architecture of the system there is an "easy" way to get to the database to make update and delete, which is through DependencyResolver . Copy code so you have an idea:
IEntityService<Persona> servicePersona = DependencyResolver.Current.GetService<IEntityService<Persona>>();
With this form I can go to the base and make inquiries in the following way:
Persona resultPersona = new Persona();
resultPersona = servicePersona.Queryable().ToList().Where(c=>c.CuilCuit==Id).FirstOrDefault();
This works perfect, the problem is when I want to make update / delete, since I do not make an assignment, but I make a direct call to a non-initialized class:
IAssistant<Persona> servicePersona2 = DependencyResolver.Current.GetService<IAssistant<Persona>>();
It should be easy to delete with the following code:
servicePersona2.Service.Delete(servicePersona.Queryable().ToList().Where(c => c.CuilCuit == "1111111111").FirstOrDefault());
servicePersona2.UnitOfWork.SaveChanges();
The problem is that I get the following error:
Did anyone have the opportunity to do an update / delete in a similar way? How did they resolve the initialization? Thanks!