Query 3 tables using LINQ and return a Json object

0

How do I query the database between 3 tables using LINQ returning a JSON object following the Structure below?

Public class PedidoGrupo{

    int id ;
    string nome ;
    public virtual List<Pedido> pedidos ;

}

    Public class Pedido{

    int id ;
    int id_PedidoGrupo;
    string destino;
    public virtual List<Pedido> ItensPedidos ;

}

    Public class PedidoItem{

    int id ;
    int id_Pedido;
    string produto;
    string marca;
    string modelo;


}


{  "id": 1,
"Nome": "Rafael",
"pedidos": [{"id":1
            "Destino":"SaoPaulo"
            "ItensPedidos": [{"Produto":"celular",
                             "marca":"Apple",
                             "modelo":"Iphone7"
            }
         ]
    }

That is, I am comparing similar id's and want to return an array of objects within the OrdersItems that are inside the requests, which in turn is inside the GroupItems.

What is the correct way to do this? I'm having a hard time.

    
asked by anonymous 25.05.2017 / 21:51

0 answers