Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 846
Shane Grant Avatar asked Jun 19 '26 22:06

Shane Grant


1 Answers

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");
like image 99
moi_meme Avatar answered Jun 22 '26 10:06

moi_meme