c# - Access foreign key in LINQ Where? -


i have entity called driver , list of drivers, call:

list<driver> drivers = _context.drivers.select(x=>x); 

driver can have details , foreign key between them, can't do:

list<driver> drivers = _context.where(x=>x.id == id && x.detail.id == detailid); 

how can foreign key properties in clause?

i using entity framework 3.5.

the statement works, although not sure (x=>x) necessary, haven't compiled it:

list<driver> drivers = _context.drivers.select(x=>x); 

the problem driver entity has foreign relation detail, driver has detailid column foreign key detail table , since using entity framework 3.5, can't driver.detail.id or driver.detailid. don't come up. did read ef 3.5 not including foreign keys , having choice in ef 4, on ef 3.5 now.

i did try .include("detail"), gave me exception detail not being navigation property.

use include method in case. ref msdn


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -