tags:

views:

38

answers:

2
+1  Q: 

linq join query

Hi, im trying to do a join in linq , however for some reason i cant access the primary key of a table. It's the 'h.ProjectId' that doesn't seem to be accepted. The following error is given CW1.SearchWebService.Bid does not contain a definition for 'ProjectId' and no extention method 'ProjectId' accepting a first argument of type 'CW1SearchWebService.Bid'

var allProjects = ctxt.Project.ToList() ;
     var allBids = ctxt.Bid.ToArray();// return all bids

            var projects = (from project in allProjects
                            join h in allBids
                              on
                           project.ProjectId equals  h.ProjectId
A: 

Perhaps the LINQ schema was generated before the field was added to the database. If it was generated with sqlmetal, try running sqlmetal over your database again. Otherwise just add it using the designer.

Marcelo Cantos
+1  A: 

The problem, according to your error message, is the h.ProjectId. The error message says that the "Bid" class (CW1.SearchWebService.Bid) does not contain a member ProjectId, so the statement fails.

You should revisit your classes, and see what the proper join option would be. If you are sure that field should be in the table, you may need to regenerate your schema.

Reed Copsey