简体   繁体   中英

How do I work with a join table in LINQ?

Struggling with my LINQ for a many to many join table :-(

I have College, Student and StudentApplications entities.

A College has many StudentApplications

A Student has many StudentApplications (for a number of different Colleges)

How do I best get all the Students that have applied to a College?

I'd prefer to use Lambda expressions.

Or if you can point to a good online tutorial that could help me work it out myself even better!

EF Core BUG

While implementing based on the answer (thanks for that) I came across a bug in EF 7/Core in this area. I raised the following issue:

https://github.com/aspnet/EntityFramework/issues/5084

students.Where(s => s.Applications.Any(a => a.College == searchCollege));

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