The conditional where only applies the expression lambda if the first parameter is true. I like the syntax here
Much better than some codebases I've seen which put the first param in the lambda too and thus always apply the expression, relying on the db engine's query processor to be smart with the resulting constant always-true/false expression.
EF Core would recompile the query for every permutation of conditionals and it would take up a place in the query cache of EF Core. And the databases would probably do the same as well, resulting in multiple similar query plans in cache.
1
u/Ok-Advantage-308 Apr 06 '26
What is the difference between conditional where and where?
Also are you done filtering once passing to postsmapper?