开发者

Entity Framework filter on foreign key

开发者 https://www.devze.com 2023-01-18 17:12 出处:网络
Dep开发者_Go百科ot_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

Dep开发者_Go百科ot_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?


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);
0

精彩评论

暂无评论...
验证码 换一张
取 消