sql - LINQ; How to perform left outer join with multiple conditions? -


i'm trying imitate:

db1 left outer join db2 b  on a.[currency code] = b.[currency code]  , a.[document date] >= b.[starting date]  , a.[document date] <= b.[ending date] 

this have now:

from ledgers in ledgerentries join currency in currencyexchange     on ledgers.currencycode equals currency.currencycode         c currencies in c.defaultifempty()     ledgers.documentdate >= currencies.startingdate     && ledgers.documentdate <= currencies.endingdate 

i've read creating anonymous type , setting them equal each other, doesn't work when using less , greater comparing dates.

it seems this answer looking for.

from ledgers in ledgerentries join currency in currencyexchange     on ledgers.currencycode equals currency.currencycode         c currencies in c.where(currency => currency.startingdate <= ledgers.documentdate  && currency.endingdate <= ledgers.documentdate).defaultifempty() 

combined this answer, able simplify to:

from ledgers in ledgerentries currencies in currencyexchange.where(     currency => currency.currencycode == ledgers.currencycode     && currency.startingdate <= ledgers.documentdate      && currency.endingdate <= ledgers.documentdate).defaultifempty() 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -