Can someone please help? I need to return the table to Extn_In_Call_Records = Extn_Number, and if either side does not match, return the value of calue in the same way as SQL Full Outer join. I spent hours looking at it, but can't get it to work! I can get the code to work below if I remove the union, but then it only returns matching results. Datatable is populated from MYSQL. Any help would be great.
DataTable fullext = new DataTable();
fullext.Columns.Add("Extn_In_Call_Records", typeof(string));
fullext.Columns.Add("Total_Calls", typeof(int));
fullext.Columns.Add("Extn_Number", typeof(string));
fullext.Columns.Add("Phys_Switch_Name", typeof(string));
try
{
var result = from callrc in callrecdt.AsEnumerable()
join physex in physextns.AsEnumerable()
on callrc["Extn_In_Call_Records"] equals physex["Extn_Number"]
.Union
from physex in physextns.AsEnumerable()
join callrc in callrecdt.AsEnumerable()
on physex["Extn_Number"] equals callrc["Extn_In_Call_Records"]
select fullext.LoadDataRow(new object[] {
callrc["Extn_In_Call_Records"],
callrc["Total_Calls"],
physex["Extn_Number"] == null ? "" : physex["Extn_Number"],
physex["Phys_Switch_Name"] == null ? "" : physex["Phys_Switch_Name"]
}, false);
result.CopyToDataTable();
fullresult.DataSource = fullext;
Viewing result
Extn_In_Call_Records Total_Calls Extn_Number Phys_Switch_Name
null 20 0 Hospital
null 310 1 Hospital
4 132 4 Hospital
2004 null null Hospital
2006 2 2006 Hospital
source
share