Return all related entities with Entity Framework

Viewed 7779

I'm playing with Entity Framework for the first time. I'm writing the following simply query:

public List<Request> GetResult(string code)
{
    List<Request> requests = new List<Request>();

    using (var db = new Context())
    {
        requests = (from c in db.Requests where c.Code == code select c).ToList();
    }

    return requests;
}

There are a few related entities to the Request object such as a Results table that has a 1-to-1 relation with the Request table. However they are all coming back null.

How can I query with Entity Framework and return a entity and ALL its related entities?

TIA

2 Answers
Related