I have a mssql database for my website within 4 tables.
When I use this:
public static string GetAllEventsForJSON()
{
using (CyberDBDataContext db = new CyberDBDataContext())
{
return JsonConvert.SerializeObject((from a in db.Events where a.Active select a).ToList(), new JavaScriptDateTimeConverter());
}
}
The code results in the following error:
Newtonsoft.Json.JsonSerializationException: Self referencing loop detected for property 'CyberUser' with type 'DAL.CyberUser'.
Path '[0].EventRegistrations[0].CyberUser.UserLogs[0]'.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…