Dave Bell

Dave Bell

  • 1.3k
  • 108
  • 7.2k

Linq Query help

May 18 2023 2:28 AM

Hello,

Below query works fine in SQL

  SELECT A.Email
  FROM [model].[dbo].[AspNetUsers] A, [model].[dbo].[SolUserStudent] C
  where A.Id = C.SolUserId and
 A.Id NOT IN (SELECT [SolUserId] FROM [model].[dbo].[SolUserStudent] where SolStudentId = 'A50F9946-01DE-434A-8791-27B179ED153D')

Can anyone help in how to convert the same in LINQ. I have got so far but struggling how to put in the NOT IN

                   var users = await (

                            from user in _context.SolUser

                            join sol in _context.SolUserStudent

                                on user.Id equals sol.SolUserId    

                                where user.Id ??? (from o in _context.SolUserStudent where o.SolStudentId == request.Id select o.SolUserId)

                                select user).ToListAsync();


Answers (4)