Using LINQ with multiple conditions (&&)

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.
 
M

Martin Honnen

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top