Note that there are some explanatory texts on larger screens.

plurals
  1. POLINQ with multiple left join and where clause
    text
    copied!<p>I have following query, and I am converting it to LINQ.</p> <pre><code>select acq.ACQPub as Prev_ACQPub , ve.CompanyID , ve.EntityID , ve.RoundID , ve.EntityName , ve.Date , ve.RoundTypeCode , ve.EventType , ve.PostValue_DJVS , ve.PostVal , ve.PreVal , fin.FinanceStat from ValuationEvents_PIT_New as ve left join Acq_PublicDummy as acq on ve.EntityID = acq.EntityID left join FinStat_New as fin on ve.EntityID = fin.EntityID where ve.EventType in('ACQ','LBO') and acq.ACQPub is null </code></pre> <p>I wanted to double check if I've done it right or there is a better way of doing it.</p> <p>Here is my code:</p> <pre><code>return (from ve in valuationEvents where ve.EventType == EventTypes.Acq || ve.EventType == EventTypes.Lbo join acq in acqPublicDummies on ve.EntityId equals acq.EntityID into veAcq from x in veAcq.DefaultIfEmpty() where x != null &amp;&amp; x.ACQPub == null join fin in finStats on ve.EntityId equals fin.EntityID into veFin from y in veFin.DefaultIfEmpty() select new AcqResearch { PrevAcqPub = x == null ? null : x.ACQPub, EntityId = ve.EntityId, CompanyId = ve.CompanyId, RoundId = ve.RoundId, Date = ve.Date, RoundTypeCode = ve.RoundTypeCode, EventType = ve.EventType.ToString(), PostValueDjvs = ve.PostMoneyValue, PostVal = ve.PostVal, PreVal = ve.PreVal, FinanceStat = y == null ? null : y.FinanceStat }).ToList(); </code></pre> <p>Since result will be used > 1 times I am returning List instead of IEnumerable. </p> <p>Also I can't run SQL and compare result of it with LINQ result, since query above runs against of Raw data and LINQ is running after data calculations and additional cleansing process. So there is no way for me to compare query result with my LINQ result. I just need to rely that logic is correct. What is the same is SQL logic and LINQ logic.</p> <p>Thank you very much for your help and feedback!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload