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()