score:2

The problem is in:

from ccfa in ccfaJoin.DefaultIfEmpty(new EmployeeCustomFormAttributeHeader())

Such a query construction should be used only with collections like db sets or queries not DefaultIfEmpty which however is IEnumerable but EF Core treats it as single value (which really in sql query result is null if there is no match) wherever it is used.

You should change it to:

let ccfa = ccfaJoin.DefaultIfEmpty(new EmployeeCustomFormAttributeHeader())

And it should work as expected.


Related Articles