0

SELECT distinct [Taskid] FROM[Dbimg].[dbo].[table1] where Taskid not in (select Taskid from[Dbimg].[dbo].[table1] where ValidationFlag is null)

Please help to convert above sql query in linq c#.

SDM
  • 15
  • 4
  • Where db is the linq data context – SDM Sep 21 '20 at 17:34
  • Perhaps my [SQL to LINQ Recipe](https://stackoverflow.com/questions/49245160/sql-to-linq-with-multiple-join-count-and-left-join/49245786#49245786) might help you. – NetMage Sep 21 '20 at 17:59

1 Answers1

0

You can try the below code

db.table1.Where(x => !db.table1.Where(y => y.ValidationFlag == null).Select(z => z.Taskid).Contains(x.TaskId))
         .Select(x => x.TaskId).Distinct();

But in your case you can also modify the above LINQ as below as you are using the same table

db.table1.Where(y => y.ValidationFlag != null).Select(z => z.Taskid).Distinct();
Sowmyadhar Gourishetty
  • 1,843
  • 1
  • 8
  • 15