我无法使用以下加入。想法是从AceBiMonthlyDaos中找到任何新的(AumProductId和IdClient)组合,以在具有唯一ID的投资表中创建条目,如果这些AumProductId和IdClient分别存在于工具和金融账户的参考表中。
var result = (from AceBi in context.AceBiMonthlyDaos
join Inst in context.Instruments
on AceBi.AumProductId equals Inst.AceId
join FinAcct in context.FinancialAccounts
on AceBi.IdClient equals FinAcct.AceClientId
join Invst in context.Investments
on new { Inst.Id, FinAcct.Id } equals { Invst.InstrumentId, Invst.FinaAcctId} into pair
from InvestmentDao in pair.DefaultIfEmpty()
var query = (from AceBi in context.AceBiMonthlyDaos
join Inst in context.Instruments on AceBi.AumProductId equals Inst.AceId
join FinAcct in context.FinancialAccounts on AceBi.IdClient equals FinAcct.AceClientId
join Invst in context.Investments on new { instrumentId = Inst.Id, finAccountId = FinAcct.Id } equals new { instrumentId = Invst.InstrumentId, finAccountId = Invst.FinAcctId }
into pair
from Invst in pair.DefaultIfEmpty()
select new { Inst, FinAcct, Invst }).Distinct();