I have hierarchy wherein a Department contains Teams and Teams contain Delegates. What I'm trying to do is get a list of Delegates that exist under a given Department. I tried doing it this way:
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;
But the teams collection doesn't allow you to refer to a particular property as if it were a collection. What I'm trying to say is "Select all the Delegates with TeamIDs in the teams collection."
var TeamDelegates = from tds in db.J_TeamDelegates
where teams.Any(x => x.TeamID == tds.TeamID)
select tds;
I think you can use a join here.
var TeamDelegates = from tms in db.Teams
where tms.DepartmentID == DepartmentID
join tds in db.J_TeamDelegates on tms.TeamID equals tds.TeamID
select tds;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With