-
-
Notifications
You must be signed in to change notification settings - Fork 231
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
UseParameterizedNamesInDynamicQuery set to true breaks OfType
method call
#722
Comments
@yonguelink I keep you informed. Or you can also create a PR. |
I'll get back to this in ~12h, if no PR has been created by then I'll check the unit tests! |
I added a (failing) test in #723 & then added a fix that I think follows the original pattern. Let me know if there's anything to improve! |
…e function (#723) * Test UseParameterizedNamesInDynamicQuery TypeOf use-case This test fails * Handle case where expression is MemberExpression This fixes #722 * Check TryUnwrapAsConstantExpression output before calling resolve --------- Co-authored-by: Isaac Ouellet-Therrien <[email protected]>
Hi @StefH , is the 1.3.4 release coming soon? We'd love to take advantage of this fix |
@pascalmartin / @yonguelink |
1. Description
We are working with the lib to generate linq queries from strings and we recently found the setting
UseParameterizedNamesInDynamicQuery
, which we see as a nice speed optimization. We updated our parameters to set that to true, and now we have a problem with the.OfType("type")
method -System.Linq.Dynamic.Core.Exceptions.ParseException: The 'OfType' function requires the argument to be not null and of type ConstantExpression.
Our usage looks like this (abbreviated a whole lot for simplicity):
2. Exception
If you are seeing an exception, include the full exception details (message and stack trace).
3. Fiddle or Project
I am not quite able to setup a reproduction in Fiddle right now, nor provide a (private) project - this is really deep into convoluted code - I'll look further into this if it is required to help you figure out the problem.
Our usage looks like this (abbreviated a whole lot for simplicity):
4. Any further technical details
I dug around in the code and from what I could understand setting
UseParameterizedNamesInDynamicQuery
totrue
makes it so that theExpression
that ends up reachingExpressionParser.ResolveTypeFromArgumentExpression
is aMemberExpression
instead of the expectedConstantExpression
, making theswitch (argumentExpression)
fall into the default case which throws the above exception.To confirm my hypothesis I did a dirty check right before the
switch
:and that fixed the problem we were hitting with the
OfType
method.The text was updated successfully, but these errors were encountered: