I am new to LINQ. I am using LINQ to Objects (I think) and a way to tune data. I cannot directly get the part of the data that I need. This is the general structure of what I need:
FROM Project
LEFT OUTER JOIN TechnologySectors
LEFT OUTER JOIN SelectedAgencies
LEFT OUTER JOIN ProjectStatus
JOIN Process
I need a separate piece of data from the process. So far I have figured out how to make a LEFT OUTER JOIN with LINQ using DefaultIfEmpty(), but I cannot figure out how to get the process to connect to ProjectStatus.
So far I have this (ps - ProjectStatus):
join ec in this._Process.GetProcessList() on ps.ProcessID equals ec.ProcessID into psec
but it gives me the error that "ps is not in scope on the left side equals".
EDIT
For reference, the “connection” that I turned on is not the whole operator. ProjectStatus (ps) joins Project (pr), and I also need Process (ec).
ec is not directly related to pr, and therefore it needs to be combined through ps. Turning the on statements over does not solve the problem.
EDIT 2
Complete LINQ query:
from pr in this._projectRepo.GetAllProjects()
join tr in this._techRepo.GetTechnologySectors() on pr.TechnologySectorID equals tr.TechnologySectorID into prtr
join ev in this._ecEnvRepo.GetAllSelectedAgencies() on pr.ID equals ev.ID into prev
join ps in this._ecProjectStatRepo.GetAllECProjectStatus() on pr.ID equals ps.ID into prps
***THIS LINE***join ec in this._ecProcessRepo.GetProcessList() on ps.ProcessID equals ec.ProcessID into psec
from tr in prtr.DefaultIfEmpty()
from ev in prev.DefaultIfEmpty()
from ps in prps.DefaultIfEmpty()
from ec in psec.DefaultIfEmpty()
This does not work.
I also tried to take out this line and just used this:
from ec in this._ecProcessRepo.GetProcessList() where (ec.ProcessID == ps.ProcessID)
And I tried using this instead of the ps and ec lines:
from ps in this._ecProjectStatRepo.GetAllECProjectStatus() where (ps.ID == pr.ID)
join ec in this._ecProcessRepo.GetProcessList() on ps.ProcessID equals ec.ProcessID into psec
from ec in psec.DefaultIfEmpty()
source
share