views:

22

answers:

1

Depot_ID is a foreign key in the database table Address. In my entity model i noticed that the foreign keys are not listed in the diagram

var Address = db.ADDRESS.Where(a => a.Depot_ID == id.Value);

This does not work as Depot_id is a foreign key in the Address table. What do I need to do to filter on this field?

A: 

You reference the ID via the navigation property. You don't say what your class properties are named, but the general idea is:

var Address = db.ADDRESS.Where(a => a.Depot.Depot_ID == id.Value);
Craig Stuntz
As an aside, I'm a big fan of Joshua Slocum's books on sailing.
Craig Stuntz
haha you're the first person to catch that...yes they are good books.
Joshua Slocum