内部加入 Entity Framework
Inner join in Entity Framework
我构建的以下查询一直存在问题,它保持 returning 为 null,我希望有人能为我指出正确的方向。
该查询旨在 return 根据给定的服务 ID 提供特定服务的分支机构列表。我在分支和服务这两个表之间存在多对多关系。
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 语法了吗?
这是有效查询,请调整 table 名称以匹配您的名称:
database.Services.Where(s => s.ServiceId == 3).First().Branches.ToList();
我构建的以下查询一直存在问题,它保持 returning 为 null,我希望有人能为我指出正确的方向。
该查询旨在 return 根据给定的服务 ID 提供特定服务的分支机构列表。我在分支和服务这两个表之间存在多对多关系。
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 语法了吗?
这是有效查询,请调整 table 名称以匹配您的名称:
database.Services.Where(s => s.ServiceId == 3).First().Branches.ToList();