Hi
I have a main problem which i created in thread (please read it before this thread). Anyway, After a lot of digging & debugging my code, I Think the problem is related to serializing lstPackageDetails to TempData via this method :
private void SetPackageDetailsList(List<DefaultVisitProductDetails> lstPackageDetails) { TempData["_lstPackageDetails"] = JsonConvert.SerializeObject(lstPackageDetails, Formatting.Indented, new JsonSerializerSettings { PreserveReferencesHandling = PreserveReferencesHandling.Objects }); }
I call above method in my Edit action to serialize my packageDetails & store in TempData, :
public IActionResult GetPackageDetails(string id) { if (id == null) { return NotFound(); } Guid gidPackageHeaderRowID = Guid.Parse(id); List<DefaultVisitProductDetails> packageDetails = _dbContext.DefaultVisitProductDetails.Where(d => d.DefaultVisitProductHeaderRowID == gidPackageHeaderRowID).OrderBy(d => d.ProductID).Include(d => d.Product).ToList(); this.SetPackageDetailsList(packageDetails); // Call it! return PartialView("_PackageDetailsList", packageDetails); }
The problem is that, after calling 'SetPackageDetailsList' method, all packageDetails which have my productIDs being loaded into dbContext!
I think there is a bug in JsonConvert (or someThing else).
Can anybody have idea to store my packageDetails list into TempData without JsonConvert (or solve above problems)?
Thanks in advance