1

I am trying to do a join in linq , however for some reason I can't 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'

Code:

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)
1
  • 1
    As an aside, why do you fetch projects and bids into memory before joining? Better to let the database do the join. (If it's just for diagnosing this problem, that's fine.) Commented Apr 2, 2010 at 0:35

2 Answers 2

1

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.

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.