Outter joins in LINQ query

56 views Asked by At

This code works good it takes and matches all the unit_no and vehiclename together but it only shows the matches i also need the ones that dont match on. I am loading a datagrid in WPF with SQLserver data and another Datagrid from 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 => 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();
0

There are 0 answers