Repository navigation
Controversial: Allow parameter values to be obtained along with query string - #19334
Closed
ajcvickers wants to merge 1 commit into
Closed
ajcvickers wants to merge 1 commit into
ajcvickers wants to merge 1 commit into
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.
ajcvickers
requested review from
AndriySvyryd,
bricelam,
maumar,
roji and
smitpatel
December 16, 2019 22:41
AndriySvyryd
approved these changes
Dec 17, 2019
roji
approved these changes
Dec 17, 2019
roji
left a comment
Member
There was a problem hiding this comment.
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?
Contributor
Author
|
@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. |
Contributor
Author
|
Notes from design meeting:
|
ajcvickers
added a commit
that referenced
this pull request
Dec 19, 2019
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
Contributor
Author
|
Superseded by #19368 |
ajcvickers
added a commit
that referenced
this pull request
Dec 23, 2019
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #6482
Not 100% convinced we should do this. Here's my thinking: