Using LINQ with multiple conditions (&&)

  • Thread starter Thread starter K Viltersten
  • Start date Start date
K

K Viltersten

For some reason, we didn't get a query to
work for us. Are there any special
requirements when using multiple conditions
before "equals" keyword?

...from P in EP
join ST in S on P.I equals ST.EI into JoinedS

In the above pseudo-code, we didn't manage
to add another condition (i.e. AND) as
follows.

...from P in EP
join ST in S on
P.I equals ST.EI
and
P.J equals ST.EJ
into JoinedS

It's a bit shot in the dark, as my colleague
solved it using his own magic already. Still,
we'd like to know where we went wrong.
 
K said:
For some reason, we didn't get a query to work for us. Are there any
special requirements when using multiple conditions before "equals"
keyword?

...from P in EP
join ST in S on P.I equals ST.EI into JoinedS

In the above pseudo-code, we didn't manage
to add another condition (i.e. AND) as follows.

...from P in EP
join ST in S on P.I equals ST.EI and
P.J equals ST.EJ
into JoinedS

It's a bit shot in the dark, as my colleague solved it using his own
magic already. Still, we'd like to know where we went wrong.

You need to use a composite key if you want to compare multiple
properties, see http://msdn.microsoft.com/en-us/library/bb907099.aspx
 
Back
Top