0

Following are the two Queries :

var q =
from c in categories
join p in products on c.Category equals p.Category 
select new { Category = c.Name, ProductName = p.Name};
var list =q.toList();

And

var q =
from c in categories
from p in products.Where(bb => bb.Category == c.Category) 
select new { Category = c.Name, ProductName = p.Name};
var list =q.toList();

Both these queries produced the same result but which of them is efficient and best to Use ?

Syed Yawar
  • 103
  • 1
  • 9

1 Answers1

1

The Where condition must find a matching result for ALL row combinations for both tables, while Join on the other side takes only the matching rows from the second table.

Dzanan Begovic
  • 160
  • 1
  • 8