I have two Databases. They are both filled into DataTables using the GetTable1 \ GetTable2 functions.
What I am looking to do is to basically compare the datatables using LINQ.
I Have tried :
var infoQuery =
(from db1 in GetTable1().AsEnumerable()
select db1).Except
(from db2 in GetTable2().AsEnumerable()
select db2);
Also tried :
(Looks like it should be doing same as above ) :
var results = GetTable1().AsEnumerable().Except(GetTable2().AsEnumerable());
The results I get back are all the records in one table. I am looking for a return of 1 since 1 row is different between the two databases.
I am using default Equals method from Object , do I need to override that implementation to get this to work?
It has to do with the way the rows are compared. Their values are not compared their references are.
http://msdn.microsoft.com/en-us/library/bb300779.aspx
Example from MSDN: