I have a question, want to join 2 tables with same column. Table 1 has Name, LastName Columns and many other columns, Table 2 has Name, Comment and many other Columns. I want to join them with Name column and as Result should be Name, LastName, Comment and other Columns. I tried with outer left Linq but don't know how to write select new because don't know how many other columns i have.
My Table 1:
Name1 LastName ...
Niki Row ...
Hube Slang ...
Koke Mi ...
... ... ...
... ... ...
Table 2:
Name Comment ...
Koke "Hello" ...
Niki "Hi" ...
Result should be:
Name LastName Comment ...
Niki Row "Hi" ...
Hube Sland ...
Koke Mi "Hello"...
... ... ...
So i tried to concat the rows with each others. But it said that the array from table1 is longer than array from table 2. Is there another way to join it?
foreach (DataRow tbE in Table1.Rows)
{
foreach (DataRow opT in Table2.Rows)
{
if (tbE["Name"].ToString() == opT["Name"].ToString())
{
var row = Result.NewRow();
row.ItemArray = tbE.ItemArray
.Concat(opT.ItemArray).ToArray();
Result.Rows.Add(row);
}
else
Result.ImportRow(tbE);
}
}
Result.Columns.Remove(Name);