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();
Dave BellPosted May 18, 2023, 12:08 PM
Sorry I missed to mention its N:N relationship. Below worked
var users = await (
from user in _context.SolUser
join sol in _context.SolUserStudent
on user.Id equals sol.SolUserId
where !(from o in _context.SolUserStudent where o.SolStudentId == request.Id select o.SolUserId).Contains(user.Id)
select user).Distinct().ToListAsync();
Chintan SukhadiyaPosted May 18, 2023, 7:28 AM
Naimish MakwanaPosted May 18, 2023, 4:30 AM
Try below:
Thanks
Jignesh KumarPosted May 18, 2023, 3:35 AM
Hello Dave Bell,
please use this one,