DT1.AsEnumerable.Except(DT2.AsEnumerable, System.Data.DataRowComparer.Default).CopyToDataTable() and it is working well but, I want it to perform the operation based on two cols only like based on Emp No and Emp Name only this should be done it shouldn’t consider other columns…
Thnx… all I’m trying to do is I have 2 datatables…ok say A and B… I want to see what extra datarow B has that A doesn’t have so I’m using except but, that’s considering all the columns in the datatable to get the job done so i want to know if it can work only for certain cols…
any idea from ur side on how this can be done @ppr
I’m sorry @vickydas this is not quite what I wanted
Let me explain what I want to do
I have two datatables say A and B with 4 cols [No, Name, Location] and keep in mind that the location will keep varying
Now, using an except expression like DT2.AsEnumerable.Except(DT1.AsEnumerable, System.Data.DataRowComparer.Default).CopyToDataTable is a problem since it also considers the location field so, it’s giving the odd one out based on all the fields
@cybzom
I am writing from Cellphone maybe some correction needs to be done from your side
Finding the Common rows from dt1 and dt2 done with Join, Expression Syntax
(From d1 in dt1.asenumerable
Join d2 in dt2.asenumerable
On d1(“No”).toString equals d2(“No”).toString and d1(“Name”).toString equals d2(“Name”).toString
Select d2).copytodatable
So Just concat the Other cols in the Same manner, result are all dt2 rows that are Common with dt1
The result you can use later for the except Statement.