Extending EF.core SqlTranslatingExpressionVisitor, inspect parameter value

Multi tool use
Multi tool use


Extending EF.core SqlTranslatingExpressionVisitor, inspect parameter value



We've extended SqlServerSqlTranslatingExpressionVisitor and override a couple visitor methods in order to rewrite specific parts of query for certain data type / comparisons. This works as expected, but in order to optimize the resulting expression when visiting/translating a given ParameterExpression we need to inspect the corresponding parameter value.



We've spent a few days now examining code and testing different scenarios, but still at no luck. Does anyone know if query parameters (as found on QueryContext.ParameterValues) are accessible in the context of SqlServerSqlTranslatingExpressionVisitor, and if so, how? Any other ideas?



SOLVED:



Found another solution. The original approach was wrong. Due to query compilation expressions should not be altered depending on parameters. We still rewrite certain expressions in SqlServerSqlTranslatingExpressionVisitor to adopt specific SQL Server options, but independent on query parameters.



The required parameter transformations are instead move to as sub-class of ParameterExtractingExpressionVisitor, where we now do initial data type conversion as required.









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

ZTJwlinkli1NSB7 6 pZbs,YLkI,QrX4z,3aueB bkG13DBG zrZ JQ7lsYKx1D,hHvBnJsi
D93HCDJL,8kLwnIX,zjQav,uBmi,pDhYCqW4CF9 ss7vdJYQoD8UNug0guY0Lcl3nS9sT4

Popular posts from this blog

PHP contact form sending but not receiving emails

Do graphics cards have individual ID by which single devices can be distinguished?

Create weekly swift ios local notifications