Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

linq group by with count

Tags:

linq

Im trying to write query in linq

Select UserId, UserNumber 
FROM User
where UserNumber in
(Select UserNumber
        FROM User
        group by UserNumber
        having Count(UserId) = 1)

Aby hints ?

like image 857
gruber Avatar asked Feb 26 '23 20:02

gruber


1 Answers

var query = from u in User
            group u by u.UserNumber into usergroup
            where usergroup.Count() == 1
            from item in usergroup
            select new { item.UserId,item.UserNumber };
like image 83
Anthony Pegram Avatar answered Mar 28 '23 23:03

Anthony Pegram