简体   繁体   English

实体框架/ linq查询构造

[英]entity framework / linq query construction

I have the following tables: 我有以下表格:

Project: 项目:

Id
SettlementId
...

Settlement 沉降

Id
Name
AreaId

Area 区域

Id
Name
...

I need to get all settlements that belong to a particular area (i get the areaId from the selected dropdownlist) that are not part of any project. 我需要获取不属于任何项目的属于特定区域的所有结算(我从选定的下拉列表中获取areaId)。

So far this is my query: 到目前为止,这是我的查询:

var settlements = (from s in entities.Settlements
                  where s.AreaId == selectedAreaId
                  select s).toList();

Am not entirely sure how to filter out the settlements that are already part of an existing project. 不完全确定如何过滤现有项目中已经存在的住区。

Thanks for your time! 谢谢你的时间!

你试过了吗?

where s.Projects.Count() == 0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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