简体   繁体   中英

Inner join in Entity Framework

I have been having a problem with the following query I constructed it keeps returning null, I am hoping that someone could just point me in the right direction.

The query is meant to return a list of branches that offer a particular service based on a service ID that is given. I have a many-to-many relationship between two tables being branches and services.

from b in database.branches
join bs in database.branch_services on b.branch_id equals bs.branch_id
where bs.service_id == objID
select b;

您是否尝试过lambda语法?

Here is the valid query, adjust table names to match yours:

database.Services.Where(s => s.ServiceId == 3).First().Branches.ToList();

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