-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Controversial: Allow parameter values to be obtained along with query string #19334
Conversation
Issue #6482 ```C# var parameters = new Dictionary<string, object>(); var queryString = queryable.ToQueryString(parameters); ``` Not 100% convinced we should do this. Here's my thinking: * This can be useful for diagnostics/testing by providing the parameter values in a machine-readable, non string converted form. For example, imagine a profiling tool that can read the dictionary and make the parameter values available to run perf testing, get query plan, etc. * On the other hand, this could be used by people who want to use EF only to generate queries which are then executing somewhere else. This is not a goal of EF and the queries may not run in some other context, so it could give a false impression of what EF is designed to do. * But if we don't do this publicly, then I think the discussion on #6482 indicates that people are going to continue to hack EF into doing it. This could end up being more painful than just supporting the feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this adds anything more controversial beyond basic ToQueryString - if we allow getting SQL out. why not also parameters... So seems OK to me.
A thought... If we do this, should we stop adding parameters into the returned SQL as comments? I'm assuming that if people simply want to log SQL (and parameters), that's what we have logging for (including the new simple logging). So this would be more for programmatic access (profilers etc.), in which case the extra comments don't necessarily make sense?
@roji It's more controversial because it makes it even easier for people to abuse the API and use it for SQL execution in an application. |
...Core.Cosmos/Query/Internal/CosmosShapedQueryCompilingExpressionVisitor.QueryingEnumerable.cs
Show resolved
Hide resolved
Notes from design meeting:
|
Design meeting feedback on #19334 for #6482 * Formatting of the relational query string can now be overridden by providers * SQL Server overrides this to create runnable `Parameter` declarations * Tested by: * Executing the DbCommand we create when using `CreateDbCommand` * Executing a DbCommand created externally and given the generated query string
Superseded by #19368 |
Design meeting feedback on #19334 for #6482 * Formatting of the relational query string can now be overridden by providers * SQL Server overrides this to create runnable `Parameter` declarations * Tested by: * Executing the DbCommand we create when using `CreateDbCommand` * Executing a DbCommand created externally and given the generated query string
Issue #6482
Not 100% convinced we should do this. Here's my thinking: