Recommand · January 13, 2022 0

Left outer join to include null values linq lambda

I have one table in database and a list of dates as follows:

List<string> allDates = { "2021-01-02", "2021-01-03", "2021-01-04" }

Balance table:

Id, Amount, BalanceDate
1, 233, "2021-01-02"
2, 442, "2021-01-03

I need to fetch the records in Balance table with amount 0 for the missing dates. For example:

233, "2021-01-02"
442, "2021-01-03"
0, "2021-01-04"