Looks like join cannot use sets defined inside query or am I doing something wrong?
from a in new[] {
new { Id = 1 },
new { Id = 2 } }
let bees = new[] {
new { Id = 2 },
new { Id = 3 } }
join b in bees on a.Id equals b.Id
select 1;
This one gives compile time error ‘Element “bees” does not exist in the current context.’ What’s wrong with the query?
This is not legal either way you slice it – you cannot declare a range variable “in the middle” of a join – internally the let clause gets translated to a
Select()statement with an anonymous type – but you cannot useSelect()either in the middle of the join, you have to move it after the join.