-
Notifications
You must be signed in to change notification settings - Fork 2.4k
#2520 - Fixed Effort- and ODataQueryTests and a bug in ExpressionVisitor #2521
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
Conversation
|
||
// 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); |
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.
This is kind of weird :) A regular method should do the job.
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.
ya think! It is just used in this one single method and contributes to readability
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 disagree. You can use a local method instead.
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.
yeah - you're right with that.
I aleady pushed that change
|
||
// 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) |
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 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. |
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.