I have a mssql database for my website within 4 tables.
When I use this:
public static string GetAllEventsForJSON()
{
using (CyberDBDataContext d
You must set Preserving Object References:
var jsonSerializerSettings = new JsonSerializerSettings
{
PreserveReferencesHandling = PreserveReferencesHandling.Objects
};
Then call your query var q = (from a in db.Events where a.Active select a).ToList(); like
string jsonStr = Newtonsoft.Json.JsonConvert.SerializeObject(q, jsonSerializerSettings);
See: https://www.newtonsoft.com/json/help/html/PreserveObjectReferences.htm