-
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
Add CommandSource to CommandEventData #24421
Conversation
I think some sort of tag mechanism for updates (#14078) would probably be more appropriate... This approach tells you that the command is coming e.g. from SaveChanges, but you still have no idea what is being changed and how. That seems to provide limited usefulness to interceptors and the like. |
Tags for |
Wouldn't SaveChanges (and raw SQL) tags fulfill the same need? Also, assuming your application has many different things being executed by both SaveChanges and ExecuteSqlRaw, how useful is it to just know that something is SaveChanges or ExecuteSqlRaw? |
I guess it would if you are writing the queries and the interceptors but if you are writing an interceptor for others to use you probably can't rely on tags being present. |
I guess it's hard for me to imagine a generic interceptor (written for others) which cares specifically about whether a command comes from SaveChanges or ExecuteSqlRaw... Do you have any example in mind? |
I wanted to process exceptions caused by ExecuteSqlRaw but IDbCommandInterceptor fires for both ExecuteSqlRaw and SaveChanges so I needed a way to find which one caused the interception to fire. For SaveChanges I use ISaveChangesInterceptor as it gives me access to the I guess it's a very specific use case but that's where the idea came from :) |
@ajcvickers So should I implement tests for the new feature or do you want to discuss it first internally? Or maybe you want changes made to the way it is implemented? |
src/EFCore.Relational/Diagnostics/RelationalLoggerExtensions.cs
Outdated
Show resolved
Hide resolved
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.
Looking good; added some comments around avoiding breaking changes.
@ajcvickers The test failed because |
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.
Looking good! Sorry for being so slow on this.
@ajcvickers Updated |
Thanks @Giorgi! Sorry for being so slow. |
Thanks for merging @ajcvickers |
This PR is my attempt to implement #23719
If the approach looks good I can fix the failing tests and add new ones for this feature.
@ajcvickers Thoughts?