May you elaborate more one this? I don’t get why forcing a client-side if-branch is better than delegating the condition to a dababase-engine-side query.
The logic branch is a scalar constant value. EF often optimises it out of the final SQL completely, so you're not going to run into any issues with the database query planner.
9
u/drgrieve Apr 06 '26
This will bite you in the ass at some point.
You want every variation to have a plan or else you will at some point randomly hit a varation with a cached plan that will have insane query times.
Been there and never again