I'm new to Linq and SQL terminology - can someone tell me why this isn't working (syntax is not right - I can't compare u.UserID int with an Enumerable)
var projectUsers = from u in SimpleRepository.All<User>()
where u.UserID == (from i in SimpleRepository.All<ProjectUser>()
where i.ProjectID == p.ProjectID
select i.UserID)
select u;
In "english", that would we "select every user where their id matches any of (userID from ProjectUser collection where projectID == x) and give me a collection of users".
I'm also using su开发者_如何转开发bsonic3 with a SimpleRepository if that makes a difference (or allows me to use something else to make this easier).
var projectUsers = from u in SimpleRepository.All<User>()
where (from i in SimpleRepository.All<ProjectUser>()
where i.ProjectID == p.ProjectID
select i.UserID).Contains(u.UserID)
select u;
or
var projectUsers = from u in SimpleRepository.All<User>()
join u2 in SimpleRepository.All<ProjectUser>() on u.UserID equals u2.UserId
where u2.ProjectID == p.ProjectID
select u;
精彩评论