简体   繁体   中英

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.

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

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