I
inpuarg
I have 2 datatables. They are identical. I want to compare them by
cell's content. They are all same.
But dt1 == dt2 or
dt1.GetHashCode() == dt2.GetHashCode() doesn 't work.
There are big amount of rows in theese datatables . So i don 't want
to enumerate each rows. This is not efficient and unacceptable for my
current application.
So how can i compare theese datatables by their contents?
Let me describe more in detail :
I have a datatable. dtOld.
In the form load event i am filling this datatable from database and
bound it to a grid.
User may change some data in the grid. Then press save button. At this
point, i can sense which row changed (.GetChanges) and update this row
to database.
So - here is my problem begins :
After this update operation i am requerying the new table from
database and name is as dtNew datatable.
And i already have a datatable which is bound to grid. called dtOld.
I am accepting changes on dtOld.
If no other user made any changes , dtOld and dtNew are same.
In debug mode i can see that they have exact same data.
for instance both of them have 10 rows. and same data in columns.
But when i compared them c# says they are not equal. In theory they
might not equal by reference . Right. But i want to compare by their
content.
How can i manage this in efficient way ?
Regards.
cell's content. They are all same.
But dt1 == dt2 or
dt1.GetHashCode() == dt2.GetHashCode() doesn 't work.
There are big amount of rows in theese datatables . So i don 't want
to enumerate each rows. This is not efficient and unacceptable for my
current application.
So how can i compare theese datatables by their contents?
Let me describe more in detail :
I have a datatable. dtOld.
In the form load event i am filling this datatable from database and
bound it to a grid.
User may change some data in the grid. Then press save button. At this
point, i can sense which row changed (.GetChanges) and update this row
to database.
So - here is my problem begins :
After this update operation i am requerying the new table from
database and name is as dtNew datatable.
And i already have a datatable which is bound to grid. called dtOld.
I am accepting changes on dtOld.
If no other user made any changes , dtOld and dtNew are same.
In debug mode i can see that they have exact same data.
for instance both of them have 10 rows. and same data in columns.
But when i compared them c# says they are not equal. In theory they
might not equal by reference . Right. But i want to compare by their
content.
How can i manage this in efficient way ?
Regards.