Ok, I am not having much luck with this. I am new to Entity Framework, and have been fighting with this one little thing since yesterday.
Here are my tables:
- Clients (id, clientname)
- Projects (id, projectname, clientid)
- Tasks (id, taskname, projectid, statusid)
- TaskStatuses (id, statusname)
In code I am only working with one project at a time, and here is how I load that project with EF:
thisProject = (from p in dataEntity.projects
where p.id == projectID
select p).FirstOrDefault();
Then later when I load the tasks:
thisProject.Tasks.Load();
Then I set the datasource of a DevExpress XtraGrid to the loaded Tasks:
taskGridControl.DataSource = thisProject.Tasks;
Up until this point everything works as expected, and the grid shows all of the tasks for the project I have loaded. But, I also want to show the Task statusname field, and that is stored in a different table.
This was very easy with a sql join, but for the life of me I cannot figure this out.
It’s easiest to select your data out into a class that’s custom-made for this grid view: