google-code-export / dblinq2007

Automatically exported from code.google.com/p/dblinq2007
Other
0 stars 0 forks source link

variable 'x' of type 'y' referenced from scope '', but it is not defined #312

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Given 2 tables:
- Client(idClient, ..., idAddress)
- Address(idAdress, ...)
i want to list all clients, but some don't have any address recorded. So i've 
tried the following query (with "db" being my DataContext):

var qClients =
 from c in db.Client
 join a in db.Address on c.IDAddress equals a.IDAddress into subset
 from subAdd in subset.DefaultIfEmpty()
 select new { 
  c, 
  add = (subAdd == null) ? "no address" : subAdd.Street  + Environment.NewLine + subAdd.Zip + " " + subAdd.City + Environment.NewLine + subAdd.Country 
  };

But when i run the code, the above query gives the "variable 'subAdd' of type 
'Address' referenced from scope '', but it is not defined" error.
What am i doing wrong ?

Original issue reported on code.google.com by plicht...@gmail.com on 6 May 2011 at 9:44

GoogleCodeExporter commented 9 years ago
I forgot to mention that i can query both tables individually (so not a 
connection/definition problem) and also execute "normal" inner join, but then i 
don't get the clients with null idAddress.

Original comment by plicht...@gmail.com on 6 May 2011 at 10:12