Up vote 1 down vote favorite share g+ share fb share tw.
I have a problem with EF Code First and it complains about a circular reference in the generated proxies. Maybe we have a convention conflict that causes EF to create a circular reference on the fly? The dataset produces no errors when simply passed directly to the JSON serializer.
/* Assume all dependencies and namespaces are referenced and used */ ///the base object public class A { Key public int AId { set; get; } //the tree public B MyB { set; get; } } //the tree nodes public class B { Key public int BId { set; get; } public int AId { set; get; } public int ParendId { set; get; } public virtual ICollection Children { set; get; } } ///the context public class ABContext : DbContext { public DbSet As { set; get; } public DbSet Bs { set; get; } } ///later in a controller... HttpGet public JsonResult Get(string sid) { int id = int. Parse(sid); using (ABContext abc = new ABContext()) { A a = abc.As. Where(i=>i.
AId==id).Single(); return Json(a, JsonRequestBehavior. AllowGet); } } Thoughts and comments are all very welcome! Thank you, Alexander Brevig c# asp.
Net-mvc-3 entity-framework-4.1 json-encode link|improve this question edited Jul 14 '11 at 11:36Nix11.9k1742 asked Jul 14 '11 at 11:21AlexanderBrevig61.
And try making ParendId a nullable int – Eranga Jul 14 '11 at 11:39.
I had the same problem. garfbradazweb.wordpress.com/2011/09/22/m... A bit of googling, and it seems the JavaScriptSerializer has gets it knickers in a twist trying to traverse your Entity Framework objects which have relationships.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.