次のクエリがあり、それをLINQに変換しています。複数の左結合を持つLINQ where句
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
私はそれを正しくやったのか、それとも良い方法があるのかを再確認したいと思っていました。ここで
は私のコードは次のとおりです。
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 && 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();
結果は、私が代わりにIEnumerableを一覧を返しています> 1回使用されますので。
また、私はSQLを実行することはできませんし、上記のクエリがRawデータに対して実行され、LINQがデータ計算および追加のクレンジングプロセスの後に実行されているため、その結果をLINQ結果と比較できません。したがって、私がLINQ結果と照会結果を比較する方法はありません。私は論理が正しいことに頼る必要があります。同じことは、SQLロジックとLINQロジックです。
ご協力いただきありがとうございます。
greeeeeaaaat – Aducci
@Aducci - ありがとう。 –