I have a Database with two tables. Customers and Orders. There is a foreign key named Customer_Id specified in the Orders referencing the primary key Id in Customers.
I use entity framework for mappings.
I would like to the JavaScriptSerializer in order to output json format like this:
[{ 
    "Id": 1,
    "Name": "Liam",
    "Orders": [
                  { "Id" : 1, "Date": "1232144213" }, 
                  { "Id" : 2, "Date": "1232144213" } 
              ]
},
{ 
    "Id": 2,
    "Name": "Martin",
    "Orders": [
                  { "Id" : 3, "Date": "1232144213" }, 
                  { "Id" : 4, "Date": "1232144213" },
                  { "Id" : 5, "Date": "1232144213" } 
              ]
}]
Is there an easy way to achieve this? I have spend some time figuring out how to do it, but I seem to get a problem with a "cirkular reference"..
 
    