我在我的網站有4個表格的mssql數據庫。JSON.Net檢測到自回參考循環
當我使用這個:
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());
}
}
以下錯誤代碼結果:
Newtonsoft.Json.JsonSerializationException: Self referencing loop detected for property 'CyberUser' with type 'DAL.CyberUser'. Path '[0].EventRegistrations[0].CyberUser.UserLogs[0]'.
可能重複的[JSON.NET錯誤自檢參考循環類型檢測](http://stackoverflow.com/questions/7397207/json-net-error-self-referencing-loop-detected-for-type) –
會如果是,請您將我的答案標記爲正確? @Kovu –
可能重複的[實體框架自我引用循環檢測](https://stackoverflow.com/questions/19467673/entity-framework-self-referencing-loop-detected) –