简体   繁体   中英

Entity Framework 1 - 1 - * - 1 relationships

I want to get every instance of Job in which their worker's region is X from my entity context. How would I do this.

The relationships of my tables are as such:

Job to Worker = 1 - 1  
Worker to WorkerRegionGroup = 1 - 1..*  
WorkerRegionGroup to Region = 1..* - 1  //However is not explictly defined via the EF

Tables

bold means the primary key

Job
int ID
string name
string description
int worker_id

Worker
int ID
string name
int WorkerRegionGroup_ID

WorkerRegionGroup
int id
int Worker_ID
int Region_ID

Region
int ID
string name

If there is a link that you can suggest that will help me better understand linq querys and the Entity Framework, please do post it.

jobs.where(job=> job.Worker
     .where(worker=> worker.WorkerRegionGroup.Region == x).Any());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM