Value setting to null when debuging, not so much when running

almacadet

New Member
I have category that can have child-categories/root-category. When I change my root category to some other category it works but when I try to set it to \[code\]null\[/code\] (to make it root category) it does not change anything. I'm using code-first approach if that makes any difference.Here is code where I explicitly state that \[code\]category.RootCategory = null\[/code\] but it does not work, root category still is what is set previously.Controller\[code\][HttpPost]public ActionResult Edit(Category c, int? rootCategoryID){ var category = _db.Categories.Where(x => x.ID == c.ID).Single(); if (TryUpdateModel(category)) { cateogry.RootCategory = null; _db.SaveChanges(); return Content(Infrastructure.Helpers.SerializeObject(category)); } return Redirect("/admin/category");}\[/code\]Model\[code\]public class Category{ public int ID { get; set; } virtual public Category RootCategory { get; set; } virtual public ICollection<Category> ChildCategories { get; set; }}\[/code\]UpdateVery strange behavior. When I debug it and go step by step slowly it updates it, when I don't debug it or run fast it is not updating. I have no clue why it is like that.
 
Back
Top