Suppose I have two .NET DataTables populated as follows, where ID is the primary key, and where null means a DBNull.Value (not the string "null"):
|Table A | |Table B
|ID |Column1 |Column2 | |ID |Column1 |Column2 |
|1 |foo |10 | |1 |zzz |null |
|2 |baz |20 | |2 |null |99 |
I want to do a merge of these tables, where the result will be:
|ID |Column1 |Column2 |
|1 |zzz |10 |
|2 |baz |99 |
In other words, I want to merge the data from Table B into Table A, just like DataTable.Merge does, but instead of copying the entire row from table B when the IDs match, I only want to copy the fields where the data is not null.
I could write my own loops through the rows of both tables to do this, but I'm wondering if there is already a method in the libraries, so that I don't have to rewrite my own version of DataTable.Merge.