Circular reference error when outputting LINQ to SQL entities with relationships as JSON in an ASP.N
- by roosteronacid
Here's a design-view screenshot of my dbml-file.
The relationships are auto-generated by foreign keys on the tables.
When I try to serialize a query-result into JSON I get a circular reference error..:
public ActionResult Index()
{
return Json(new DataContext().Ingredients.Select(i => i));
}
But if I create my own collection of…