0
 var result = from lr in _db.LeaveRequest
                 join th in _db.TotalHourslu    
                 on lr.TotalHoursEffect 
                 equals th.Minutesselect
                     select new { lr.TotalHoursEffect, th.Minutes, tr.Display };

ERROR: The name '_db' does not exist in the current context The name '_db' does not exist in the current context The name ' tr ' does not exist in the current context

Yves
  • 12,059
  • 15
  • 53
  • 57
  • Just to make sure, is tr.Display supposed to be lr.Display? It's the same error for the same reason as _db, which will be well explained in the answers soon. However, if the tr is just a typo, then it's a different fix. – Sean Jul 07 '09 at 02:46

2 Answers2

1

That error means there are no objects named _db or tr accessible in the current context. This means there are no method-local, class-member or global variables with those names. Did you possibly copy-paste some code and forgot to rename the variables to the correct names?

Also remember that member variables in one class are not accessible from other classes unless you prefix them with "ClassName.", like NameOfClassWhereDBIsDefined._db. And that won't even work if _db is a private member, like it probably is. In that case, you would have to pass _db in as a parameter to the function, or have it accessible through a getter method/property.

Sean
  • 4,450
  • 25
  • 22
0

Did you forget to add

MyDataClassesDataContext _db = new MyDataClassesDataContext();

to your class as a member variable?

Robert Harvey
  • 178,213
  • 47
  • 333
  • 501
  • Hi Robert, thank you. I forgot to put the above datacontext. I added the above and I am still having error on: tr.Display. – Yves Jul 07 '09 at 02:50