Shane Grant
Shane Grant

Reputation: 2654

Entity Framework: Loading 2nd level navigation properties

I have the following three tables:

Clients: id clientname

Projects: id clientid (int ref to Clients.id) projectname projectstatus (int ref to ProjectStatuses.id)

ProjectStatuses: id statusname

I select a single client fine, and when needed I load the selected clients projects like this:

selectedClient.Projects.Load();

but how do I have it also load the project status name?

Upvotes: 3

Views: 3013

Answers (1)

moi_meme
moi_meme

Reputation: 9318

selectedClient.Projects.ProjectStatuses.Load()

Edit

It's a One-to-many relationship i guess,

this should work

selectedClient.Projects.First().ProjectStatuses.Load()

or you could also load it directly in your query with

context.Clients.Include("Projects.ProjectStatuses");

Upvotes: 4

Related Questions