Linq. Where versus On

S

shapper

Hello,

What is the difference between using:

from a in A
join b in B on a.Name equals b.Name
select a;

and:

from a in A
join b in B where a.Name equals b.Name
select a;

I was using "on" but on this group Jon suggested me the Where example.

Shouldn't I use the "on" in Joins and "where" when I want to impose
some condition to filter items on a condition?

Thanks,
Miguel
 
J

Jon Skeet [C# MVP]

shapper said:
What is the difference between using:

from a in A
join b in B on a.Name equals b.Name
select a;

and:

from a in A
join b in B where a.Name equals b.Name
select a;

The first is valid, the second isn't.
I was using "on" but on this group Jon suggested me the Where example.

Just a typo in a hastily written post, I'm afraid.
Shouldn't I use the "on" in Joins and "where" when I want to impose
some condition to filter items on a condition?

Yes.
 

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

Similar Threads

FindAll. Linq. 4
Linq. Aggregate 4
Property 7
Validation Rules 3
left outer join 1
newbie SQL SELECT help 3
Sub Query 2
Simulating an outer non-equijoin in LINQ. 9

Top