gpt4 book ai didi

c# - Linq where in 子句

转载 作者:太空狗 更新时间:2023-10-30 00:15:25 24 4
gpt4 key购买 nike

我有层次结构,其中部门包含团队,团队包含代表。我想要做的是获取给定部门下存在的代表列表。我试过这样做:

var teams = from tms in db.Teams
where tms.DepartmentID == DepartmentID
select tms;

var TeamDelegates = from tds in db.J_TeamDelegates
where tds.TeamID in teams.TeamID //error here
select tds;

但团队集合不允许您像引用集合一样引用特定属性。我想说的是“在团队集合中选择所有具有 TeamID 的代表。”

最佳答案

var TeamDelegates = from tds in db.J_TeamDelegates
where teams.Any(x => x.TeamID == tds.TeamID)
select tds;

关于c# - Linq where in 子句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14986533/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com