Two DataTables, outer joined on a single column. Contents/columns of table2 [t2] are constant. Contents/columns of table1 [t1] are variable, only the one joined column is a constant.
The query results are the constant columns in t2, plus the variable contents in t1:
var joined =
from t1 in Table1.AsEnumerable()
join t2 in Table2.AsEnumerable() on t1["customer_name"] equals t2["Client"]
into t1t2 from t2DR in t1t2.DefaultIfEmpty()
select new {
t1,
Firm = (t2DR == null) ? "N/A" : t2DR["Firm"].ToString(),
Primary = (t2DR == null) ? "N/A" : t2DR["Primary"].ToString(),
};
While I can select the specific (varying) columns in t1, I am looking for a generic query like the above with the results containing all of the columns in t1, plus those specified for t2. Something similar to using:
joined.CopyToDataTable();
That would return all of the columns in the t1 datarow, plus those in t2.
The only methodology I have found so far is to create a new datatable, enumerate the columns in the t1 datarow, add those then the ones from t2 and then add the rows to the new table.
Is there another method to accomplish this?