My current solution is as follows. - I want to know whether this is correct.
Inside a HttpPost action method, I have the following code:
- Case type is an entity., case variable is passed as a parameter into the action method.:
Case caseInRepository =
_unitOfWork.CaseRepository.FindById(case.Id);
caseInRepository.UpdateState(case);
_unitOfWork.CaseRepository.Update(caseInRepository);
_unitOfWork.CaseRepository.SaveChanges();
The UpdateState method maps the fields of the argument (which isare the edited fields) to the instance. Some fields are ignored, since they were not set in the view, and are null.
My question is, with entity frameworkEntity Framework, the _unitOfWork.CaseRepository.Update(caseInRepository);
_unitOfWork.CaseRepository.Update(caseInRepository);
line is not necessary, since entities are tracked. However, I am not sure if it is right to remove it, since not all data storagesstorage support change tracking. I am also not sure if it is right to call FindById to get the item from the datastore.