#2520 - Fixed Effort- and ODataQueryTests and a bug in ExpressionVisitor #2521
Merged
jbogard merged 3 commits intoLuckyPennySoftware:masterfrom Jan 31, 2018
Merged
#2520 - Fixed Effort- and ODataQueryTests and a bug in ExpressionVisitor #2521jbogard merged 3 commits intoLuckyPennySoftware:masterfrom
jbogard merged 3 commits intoLuckyPennySoftware:masterfrom
Conversation
lbargaoanu
suggested changes
Jan 30, 2018
|
|
||
| // check if the non-string expression is a null constent | ||
| // as this would lead to a "null.ToString()" and thus an error when executing the expression | ||
| var isNullConstant = new Func<Expression, bool>(xpr => xpr is ConstantExpression c && c.Value == null); |
Contributor
There was a problem hiding this comment.
This is kind of weird :) A regular method should do the job.
Contributor
Author
There was a problem hiding this comment.
ya think! It is just used in this one single method and contributes to readability
Contributor
There was a problem hiding this comment.
I disagree. You can use a local method instead.
Contributor
Author
There was a problem hiding this comment.
yeah - you're right with that.
I aleady pushed that change
lbargaoanu
approved these changes
Jan 30, 2018
lbargaoanu
reviewed
Jan 30, 2018
|
|
||
| // check if the non-string expression is a null constent | ||
| // as this would lead to a "null.ToString()" and thus an error when executing the expression | ||
| bool IsNullConstant(Expression xpr) |
Contributor
There was a problem hiding this comment.
I think it looks much better after the function body, like in the docs. Easier on the eyes :)
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fix for #2520
The ExpressionMapper has the following bug.
In ExpressionMapper.VisitBinary, it compares the types of the two expressions.
If one is of type string and the other is not, it adds a "ToString()" to the expression.
However, it does not check for the "null Constant".
Therefore, the OData query of ODataQueryTests.CanFilter_FullNameEndsWith converts the following DTO expression:
to the following Entity expression:
As you can see, the Entity expression contains a ".Call null.ToString()" which results in an InvalidOperationException in EntityFramework.