Hi,
I have two related tables: Areas and Routes. An Area is assigned to a Route and a Route can have many Areas assigned.
I have an Area form in which I list all the areas in a data grid (this is WPF C# .NET 3.5). I want to list the Route that each area belongs to in this grid as well. My code to pull back all the Areas is this:
IQueryable<AreaEntity> query = from Area in this.ObjectContext.AreaEntitySet
select Area;
I have tried this:
IQueryable<AreaEntity> query = from Area in this.ObjectContext.AreaEntitySet
join Route in this.ObjectContext.RouteEntitySet on Area.are_rtefk equals Route.rte_pk
select Area, Route;
which gives me this error:
A local variable named 'Route' cannot be declared in this scope because it would give a different meaning to 'Route', which is already used in a 'child' scope to denote something else
I would actually like something like this:
IQueryable<AreaEntity> query = from Area in this.ObjectContext.AreaEntitySet
join Route in this.ObjectContext.RouteEntitySet on Area.are_rtefk equals Route.rte_pk
select Area, Route.rte_name;
to just pull out the rte_name field, but that gives me this error:
Only assignment, call, increment, decrement, and new object expressions can be used as a statement
Anyone can help this linq and .net newbie?