Search code examples
c#linqsql-to-linq-conversion

SQL Except Syntax in C# Linq


I have exported the data in datatable in SQL server for testing, and I have ended up with a query of :

Select * from @tempTable1
Except
Select * from @tempTable2

How can i write this statement in Linq C#? I already have 2 DataTable that represent the @tempTable1 and @tempTable2 in my C# code


Solution

  • You Can Try This :

    DataTable dtmismatch = Table1.AsEnumerable().Except(Table2.AsEnumerable(), DataRowComparer.Default).CopyToDataTable<DataRow>();