Description
Our SQL cache (currently) only caches by the nullability of the parameters; that means that if anything looks at something other than the nullability of a parameter, we must disable SQL caching to prevent cached SQL from leaking incorrectly across queries. Currently, we have to remember to call DoNotCache() in e.g. SqlNullabilityProcessor - this is error-prone, and if we forget this it can have subtle, hard-to-detect effects.
Instead of exposing the parameters directly, we should expose a façade wrapping the parameter dictionary which:
- Allows checking if a given parameter is null (no problem there)
- Allows getting the full dictionary, but disables caching automatically as part of that.
This would ensure that anyone getting the parameters implicitly causes caching to be disabling, removing the possibility for this category of bugs.
In addition, do general clean up around the parameters dictionary, removing IParameterValues etc.. Components of the query pipeline up to the SQL cache which have access to parameters (e.g. funcletizer) should just be able to access the Dictionary<string, object?>
directly - no need for a special API to get in the way.
This work on parameter handling in the query pipeline also goes well with #35089 which is also in 10.