Circular Links and ScriptIgnore Issues

I have several BusinessObject classes that reference each other, and I need to serialize them to JsonResponse and return it to my view. I keep getting the circular link exception, and I cannot get rid of it. I put a decorator [ScriptIgnore()]on every property that is not a simple data type property, and I still get an exception. I can't figure out where the problem is, because I am blocking the serializer from everything, and it still explodes.

Is there any way to see what the current state of a serialized object is?

    [HttpPost]
    public JsonResult GetAnalysisInfo(int id)
    {
        ProjectContext myDB = db;
        SearchAnalysis searchanalysis = SearchAnalysis.Find(myDB, id);
        //searchanalysis.Results = searchanalysis.SearchResultsPrototype(myDB);
        return this.Json(searchanalysis);
    }

Update

I also tried to implement ISerializable to no avail. My GetObjectData is very simple:

    public void GetObjectData(SerializationInfo info, StreamingContext context)
    {
        info.AddValue("SearchAnalysisId", this.SearchAnalysisId);
        info.AddValue("Created", this.Created);
    }

- CircularRefernce. DateTime ?

+4
1

, , , :

    public JsonResult CompanyListJson()
    {
        var list = (from companies in appContext.Companies
                    where companies.Active.Equals(true)
                    select new
                    {
                        Name = companies.DbName,
                        Id = companies.Id,
                        Active = companies.Id.Equals(CurrentCompany.Id)

                    });
        return Json(list, JsonRequestBehavior.AllowGet);
    }

, , JSON , (, , )

, SearchAnalysis, .

+1

All Articles