I am a beginner with C# /LINQ query - I have below query. Right outer join works fine in Simple SQL, however, I am unable to implement this in LINQ, but not getting anywhere.
SELECT bt.PosGUID,s.PosGUID
FROM tblSchedule s right Join tblTrade bt
ON s.PosGUID = bt.PosGUID AND RowType = '4'
SELECT bt.PosGUID,s.PosGUID
FROM tblTrade bt left Join tblSchedule s
ON s.PosGUID = bt.PosGUID AND RowType = '4'
I need to understand what is the best way to the above left outer join, I guess right outer join is not possible, hence converted to left join and trying to implement.
Something like - seems to be bit complex query :
var tQuery = from bt in m_DataContext.tblTrades
join bPos in m_DataContext.tblBigPositionStatics on
new { bt.PosGUID } equals
new { bPos.PosGUID }
join bo in m_DataContext.tblBigOrders
on new { bt.ClOrdID, bt.PosGUID } equals new { bo.ClOrdID, bo.PosGUID }
join tradingAcc in m_DataContext.tblTradingAccounts
on new { Entity = bPos.PosEntity, Account = bPos.PosAccount } equals
new { tradingAcc.Entity, tradingAcc.Account }
join btRef in m_DataContext.tblTrades.DefaultIfEmpty()
on new { bt.PosGUID, ExecID = bt.ExecRefID } equals new { btRef.PosGUID, btRef.ExecID }
into temp
from btref in temp.DefaultIfEmpty()
join desk in m_DataContext.tblDesks
on bt.PosDeskGUID equals desk.GUID
// JOIN not working not briging back all records from TBLTrades
join ss in m_DataContext.tblSchedules on bt.PosGUID equals ss.PosGUID into temp1
from ss in temp1.DefaultIfEmpty()
where bt.CreateDateTime >= dateToRun.getDate(false)
&& bt.CreateDateTime < dateToRun.getDate(false).AddDays(1)
&& bo.AsOfDateTime.Date == bt.AsOfDateTime.Date
&& bPos.HardDeleteDate == null
&& ss.RowType == "4"
//&& !"1".Equals(bt.ExecTransType)
//&& bt.HasBeenCorrected == false
&& deskGuidList.Contains(desk.GUID)
select new { bt, bo, desk, bPos, tradingAcc, btref,ss };