Skip to content
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

Delay DbCommandInterceptor.CommandCreated until DbCommand properties are initialized #17261

Closed
divega opened this issue Aug 19, 2019 · 2 comments · Fixed by #27884
Closed

Delay DbCommandInterceptor.CommandCreated until DbCommand properties are initialized #17261

divega opened this issue Aug 19, 2019 · 2 comments · Fixed by #27884
Labels
area-interception closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Milestone

Comments

@divega
Copy link
Contributor

divega commented Aug 19, 2019

I was hoping I could now log the CommandText from this method without having to override Execut* methods, but the DbCommand exposed as the result of CommandCreated is empty.

We discussed with @ajcvickers that having the properties populated could be more useful, but it is likely we don't have time to change this for 3.0 RTM, in which case we can add "CommandInitialized" method later.

@divega divega changed the title Consider delaying DbCommandInterceptor.CommandCreated until properties are intialized Consider delaying DbCommandInterceptor.CommandCreated until DbCommand properties are intialized Aug 19, 2019
@ajcvickers ajcvickers added this to the Backlog milestone Aug 23, 2019
@ajcvickers ajcvickers self-assigned this Aug 23, 2019
@ajcvickers
Copy link
Member

Compare to #15988

@simeyla
Copy link

simeyla commented Feb 14, 2021

@ajcvickers I was excited to see the following in the EF Core 5 New Features:

"In addition, it is now possible to call ToQueryString on any LINQ query, retrieving the SQL that the query would execute"

I've added my own DBInterceptor to add NOEXPAND hints and it works great.

However if I run ToQueryString() during debugging I won't see my hint in the SQL since I am relying on ReaderExecutingAsync and ReaderExecuting to perform the modification of the underlying command string.

It seems a shame that CommandCreating and CommandCreated seem to be intended only for fully comprehensive interception, but not for the simpler cases. It would also be nice not to have to consider overloading both ReaderExecutingAsync and ReaderExecuting.

I know it's sort of an edge case and easy to work around but wanted to add this as part of this conversation.

@ajcvickers ajcvickers modified the milestones: Backlog, 7.0.0 Apr 25, 2022
@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Apr 25, 2022
ajcvickers added a commit that referenced this issue Apr 25, 2022
@ajcvickers ajcvickers modified the milestones: 7.0.0, 7.0.0-preview5 Apr 26, 2022
@ajcvickers ajcvickers changed the title Consider delaying DbCommandInterceptor.CommandCreated until DbCommand properties are intialized Delay DbCommandInterceptor.CommandCreated until DbCommand properties are initialized Jun 23, 2022
@ajcvickers ajcvickers modified the milestones: 7.0.0-preview5, 7.0.0 Nov 5, 2022
@ajcvickers ajcvickers removed their assignment Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-interception closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants