I am having a list that each list item contain another list. On the time of render the column it will give me error "http://datatables.net/tn/7". I look a lot but not found any solution. Please help me to overcome by this issue.
Full Error is below
A circular reference was detected while serializing an object of type 'System.Data.Entity.DynamicProxies.tblPropertyDocument_C39281F23DAA0C224A777580A8038E1E55D91AF3EBEC9D53EF39EC1E6EAAAD0C'.
What I have tried:
Actually I have a list of objects and inside each object i have another list. When i will return data to the datatable it will generate the circular error due for the inner list items. I know why this problem occur but not get how to resolve it.
Below is my code:
var SelectedAllSending = AllSending1.Select(s => new OutgoingCommunicationVM()
{
dDate = s.dDate,
id = s.id,
cDescription = s.tblDDLSelect.cDescription,
cSubject = s.cSubject,
Recipients = (from t in db.tblRecipients where (t.nMessageID == s.id) orderby t.cName select t).Take(3).ToList(),
TotalRecords = totalRecords,
PageCount = GetPageCountUSPS(s.id, s.tblDDLSelect.cDescription),
EstimatedCost = GetCost(s.id, s.tblDDLSelect.cDescription)
}).ToList();
as you see in my code I have a list "SelectedAllSending" and inside this list I have another list by the name off "Recipients".
When i will return value to the datatable it will give me error. Below is my code.
return Json(new { draw = draw, recordsFiltered = recordsTotal, recordsTotal = recordsTotal, data = SelectedAllSending }, JsonRequestBehavior.AllowGet);
object inside object gives circular error on json return. Or how i can pass list inside list in datatable.
please help me to overcome this issue.