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.
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
[Instrumentation.EntityFrameworkCore] Fix db.statement tag for Devart Oracle #2466
base: main
Are you sure you want to change the base?
[Instrumentation.EntityFrameworkCore] Fix db.statement tag for Devart Oracle #2466
Changes from 4 commits
7b66dc5
f455d86
6e52578
a8a7651
b2ea7d8
73b0921
3369e1b
175c984
e7adb6e
f0c4f46
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Consider code below. It is doing couple of things
payloadString.Contains(
usages in new code, it is better to check bools first (cheaper).Sorry for waiting long for a feedback, it is not trivial change.
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.
@Kielek Thank you for the response and suggestions.
When this code is executed
this.commandTypeFetcher.Fetch(command)
in the IF statement, the exception will leave theEntityFrameworkCoreCommandExecuting
case (It will not step into the ELSE IF statement to check if it's Devart). This can be fixed with a try-catch statement, where the TRY part contains the original code, and the CATCH statement handles fallback:With this change we don't need to check if Devart is causing this problem or another provider for database connection.
Is this change acceptable?
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.
What's about converting it to
if (this.commandTypeFetcher.TryFetch(command, out var commandType)
, without try/catch?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.
Tried it but still throws exception unfortunately 😞
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.
Here is what I've dug up while analyzing this exception. Firstly, the Fetch function calls the TryFetch function in its implementation. The TryFetch function is implemented as:
Now if we follow the code execution,
PropertyFetch.FetcherForProperty(property);
is called with the following implementation:The return statement calls
(PropertyFetch)Activator.CreateInstance(instantiatedTypedPropertyFetcher, propertyInfo);
which calls the constructor of theTypedPropertyFetch
:When
CreateDelegate()
is called, the exception is thrownSystem.ArgumentException: 'Cannot bind to the target method because its signature is not compatible with that of the delegate type.'
.This is the part I can't solve, which is why I made this workaround.
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.
There is couple things you should consider here:
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 was writing this code based on an older version (1.0.0-beta.10) that didn't have
this.options.EmitOldAttributes
andthis.options.EmitNewAttributes
. So, I will update the code structure to follow the convention of the switch statement.Updated the line as follows:
string[] result = payloadString.Split([Environment.NewLine], 2, StringSplitOptions.None);
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.