I was looking at a co-workers Linq query, shown below (the query executes correctly):
from ea in EquipmentApplication
join erl in EquipmentRoutingLocation on ea.EquipmentID equals erl.EquipmentID into erlWithNulls
from erlAll in erlWithNulls.DefaultIfEmpty()
join rl in RoutingLocation on erlAll.RoutingLocationID equals rl.RoutingLocationID into rlWithNulls
from rlAll in rlWithNulls.DefaultIfEmpty()
where ea.Equipment.Master_Cell.Area.Unit.UnitID == 1160
select new { ea.Equipment, ea.ApplicationFriendlyName, rlAll }
I'm confused as to why this works. My understanding (perhaps incorrectly) is that the 'into' keyword ends the current scope/context (and any variables created are now out of scope) and creates a new one. If this is true, why is the 'ea' variable still in scope in the last part of the query?