LINQ Join inside Join, how to?

You just need to flip the on statement join ec in this. _Process.GetProcessList() on ec. ProcessID equals ps.

ProcessID into psec In regards to the multiple joins you should be able to chain them.

Nope, that then gives the error on ec and on ps. – James P. Wright Feb 24 at 19:52 Can you then give more of the Linq query as there might be something that we are missing.

– Mike Feb 24 at 19:57 That's because there is a typo, fixed – msarchet Feb 24 at 19:58.

You just need to swap the ec and ps around ec in this. _Process.GetProcessList() on ps. ProcessID equals ec.

ProcessID into psec To do the left join you need to do the following ec in this. _Process.GetProcessList() on ps. ProcessID equals ec.

ProcessID into nullablePsec from ec in nullablePsec.DefaultIfEmpty() There are various ways to name the objects but I usually find I write the join to go into the object name with nullable prefixed and then give it the same name again by using the next line from ec in nullablePsec.DefaultIfEmpty() EDIT: After seeing the full linq query you need to be joining like this ec in this. _Process.GetProcessList() on prps. ProcessID equals ec.

ProcessID into psec Note here the join is on the prps variable name as you are selecting into to prps in the line above it join ps in this. _ecProjectStatRepo. GetAllECProjectStatus() on pr.ID equals ps.

ID into prps The into prps has changed the variable name that you will be working with in the join query onto the process list. EDIT 2 It might work a bit better if you write the statement as follows from pr in this. _projectRepo.GetAllProjects() join tr in this.

_techRepo. GetTechnologySectors() on pr. TechnologySectorID equals tr.

TechnologySectorID into prtr from tr in prtr.DefaultIfEmpty() join ev in this. _ecEnvRepo. GetAllSelectedAgencies() on pr.

ID equals ev. ID into prev from ev in prev.DefaultIfEmpty() join ps in this. _ecProjectStatRepo.

GetAllECProjectStatus() on pr. ID equals ps.ID into prps from ps in prps.DefaultIfEmpty() join ec in this. _ecProcessRepo.GetProcessList() on ps.

ProcessID equals ec. ProcessID into psec from ec in psec.DefaultIfEmpty().

The problem with the first method you talk about is that prps does not have a ProcessID. If I try the 2nd method I get lots of Object Reference errors when I run the code. – James P.

Wright Feb 24 at 20:37.

When you do a group join, the variable from the inner sequence goes out of scope and you no longer have access to the individual elements. You need to move the associated DefaultIfEmpty() up if you want that access or not do the group join in the first place. Var 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 from ps in prps.DefaultIfEmpty() // you need to resolve `ps == null` issues here let key = ps == null?

-1 : ps. ProcessID join ec in this. _ecProcessRepo.GetProcessList() on key equals ec.

ProcessID into psec from tr in prtr.DefaultIfEmpty() from ev in prev.DefaultIfEmpty() from ec in psec.DefaultIfEmpty() // ...

Using this method ends up with an obvious lack of an OUTER JOIN because my records go from 245 to 4 because only 4 records have a ProcessID assigned to them, which is why I started trying to do this the whole time. – James P. Wright Feb 24 at 20:33 @Pselus: In that case, use the other approach I mentioned.My example used the approach that required less guessing on my side.

If you need to the outer join, move the DefaultIfEmpty() call up like I said. But you'll have to resolve the cases when it yields null values. – Jeff Mercado Feb 24 at 20:47.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions