c# - Outter joins in LINQ query -
this code works takes , matches unit_no , vehiclename shows matches need ones dont match on. loading datagrid in wpf sqlserver data , datagrid oracle data.
private void getsqloraclelinqdata() { var tstardata = gettrackstartruckdata(); var m5data = getm5data(); datatable comtable = new datatable(); foreach (datacolumn oracolumn in m5data.columns) { comtable.columns.add(oracolumn.columnname, oracolumn.datatype); } foreach (datacolumn sqlcolumn in tstardata.columns) { if (sqlcolumn.columnname == "vehiclename") comtable.columns.add(sqlcolumn.columnname + "2", sqlcolumn.datatype); else comtable.columns.add(sqlcolumn.columnname, sqlcolumn.datatype); } var results = m5data.asenumerable().join(tstardata.asenumerable(), => a.field<string>("unit_no"), b => b.field<string>("vehiclename"), (a, b) => { datarow row = comtable.newrow(); row.itemarray = a.itemarray.concat(b.itemarray).toarray(); comtable.rows.add(row); return row; }).tolist();
Comments
Post a Comment