How to use group by and having count in Linq

Posted by Luke on Stack Overflow See other posts from Stack Overflow or by Luke
Published on 2010-04-04T19:24:07Z Indexed on 2010/04/04 19:33 UTC
Read the original article Hit count: 271

Filed under:
|

I am having trouble trying to convert the following query from SQL to Linq, in particular with the having count and group by parts of the query:

select ProjectID
from ProjectAssociation

where TeamID in ( select TeamID 
                  from [User]
                  where UserID in (4))
group by ProjectID
having COUNT(TeamID) = (select distinct COUNT(TeamID)
                        from [User]
                        where UserID in (4))

Any advice on how to do so would be much appreciated.

© Stack Overflow or respective owner

Related posts about c#

Related posts about LINQ