There are some articles already on the internet which deals in this area but personally they didn’t fit my requirement due to one reason or the other.
In order to proceed with this article, I will first create two DataTable and fill them up with some random data.
The DataTable would be like the following:
DataTable 1:
DataTable 2:
Now, we will use the below LINQ query to merge the DataTable in such a way that the output is as in the following:
The code for the same is as follows:
The simple query just finds the item from both the DataTables having the common “ID” in them and gets the same in a different DataTable all together.
The output screen is as follows:
Please feel free to download the attached project for more understanding of the concept.