Click here to Skip to main content
15,882,464 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi guys

I get this error and not sure what to do, please help.

Error:"A circular reference was detected while serializing an object of type "

C#
var context = HttpContext.Current;
            int rowCount = -1;

            var property = db_Property.getEveryProperty(0, 10, "", ref rowCount);

            JavaScriptSerializer js = new JavaScriptSerializer();

return js.Serialize(new { aaData = property, count = rowCount });//Error is here




C#
//Methos contents
using (var context = new dbPropertyManagerEntities())
           {

               var query = from row in context.tbl_Property
                           select row;

               if (!string.IsNullOrEmpty(searchTerm))
               {
                   query = query.Where(row => row.propName.Contains(searchTerm) || row.propAddress.Contains(searchTerm));
               }
               query = query.OrderBy(s => s.propName);

               var qRowCount = query.Count();
               var qRow = query.Skip(skip).Take(take);

               rowCount = qRowCount;
               context.ContextOptions.LazyLoadingEnabled = false;
               return qRow.ToList();

           }
Posted
Comments
Thanks7872 10-Sep-13 5:52am    
https://www.google.co.in/search?q=A+circular+reference+was+detected+while+serializing+an+object+of+type&oq=A+circular+reference+was+detected+while+serializing+an+object+of+type&aqs=chrome..69i57&sourceid=chrome&ie=UTF-8

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900