I have the following DeletePOST action method:-
[HttpPost]
public ActionResult Delete(int id)
{
try
{
var lb = repository.GetLabTest(id, false);
repository.DeleteLabTest(lb);
repository.Save();
return Json(new { IsSuccess = "True", id = id, description = lb.Description }, JsonRequestBehavior.AllowGet);
}
//code goes here....
When I wrote the code, I thought that it will return an error on the description = lb.Description,, since I am deleting the lb object and then I am retrieving its lb.Description property value inside the return Json. But the code was able to retrieve the Description value for the object that was just deleted. So how does this happen?
BR
That IMO is because you deleted the object from the database not the memory, a copy of that object still resides in the mem in the form of
var lb, if you dothen your code will throw an exception, probably, object reference not set of the sort