I have two data tables as follows
dtOne
-------------------------
  ID  |   Name 
--------------------------
 101  |  ABC
 102  |  XYZ
 103  |  MNO
--------------------------
dtTwo
-------------------------
  ID  |   Name 
--------------------------
 101  |  ABC
 102  |  XYZ
--------------------------
I just want the result as data which is in dtOne and  not in dtTwo (dtOne-dtTwo)
dtResult
-------------------------
  ID  |   Name 
--------------------------
 103  |  MNO
--------------------------
How can i achieve this .
TO get it work its better to use Linq To DataSet will resolve it easily..
DataTable table1= ds.Tables["table1"];
DataTable table2= ds.Tables["table2"];
var diff= table1.AsEnumerable().Except(table2.AsEnumerable(),
                                                    DataRowComparer.Default);
                        Starting with the solution showed under LINQ query on a DataTable, I'd try it with:
var dtOneData = from myRow in dtOne.AsEnumerable();
var dtTwoData = from myRow in dtOne.AsEnumerable();
var difference = dtOneData.Except(dtTwoData);
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With