-
Notifications
You must be signed in to change notification settings - Fork 337
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
Implement Command and Exception Interceptors #420
Comments
Command InterceptorsThe existing API is not compatible with async command execution (a big selling point of this library). Although it could be changed to be so, that would introduce significant additional complexity. It's likely that supporting these would require code refactoring that would hurt performance (e.g., removing It's also not clear to me what a compelling use case for these interceptors is; moreover, they can easily be implemented via the "Decorator" pattern (e.g., this is how Dapper works). I tried to search GitHub for uses of command interceptors but only found copies of Connector/NET source code itself (not clients defining derived types). Exception InterceptorsMany of the same arguments apply. It's also possible to wrap exceptions (or suppress them, which isn't possible with MySQL's exception interceptors) via the decorator pattern. |
I'd raised this previously in #140. This would be analogous to IDbCommandInterceptor in EF 6, but isn't yet supported in EF Core - tracked in Lifecycle hooks but yet to be implemented. In terms of use cases it could be useful to define session variables like |
Hmm, I must have forgotten about that when I created this issue; sorry.
Does the suggestion at #519 (comment) solve this use case? (Assuming you can use the underlying ADO.NET library and attach that event handler when using EF.) |
I'd forgotten about that workaround, but that should do the trick. |
https://dev.mysql.com/doc/connector-net/en/connector-net-interceptors.html
It's configured by the connection string and loaded (via reflection) at runtime.
The text was updated successfully, but these errors were encountered: