-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Table-valued function or DbQuery with parameters #18360
Comments
@smitpatel I think there is more here than we discussed in triage; we should re-visit. It appears in 3.0 that we parameterize on the second case as well. |
@smitpatel to explain what is going on here. |
Ping @smitpatel |
In LINQ, if you use variable in a method with/without lambda it generates different expression tree.
In With above in mind, |
I have a PLSQL function which takes some number parameters and returns a table, and I would like to use it in a query. It seems to me that EF supports both table-valued functions and user-defined function translation, but not both at the same time.
If I attempt to solve this with a DbQuery, my Context contains this:
My mapping contains this:
If I use this to start a query, it works fine:
Gets translated to:
If I use it in a subquery, it starts getting slightly weird:
Gets translated to:
The parameters to getRange are now literals instead of being properly parametrized. This is not the main issue here, but I don't understand why it happens - if it's working as intended, please explain what's going on.
If the parameters need to be evaluated on the server, it doesn't work at all:
Throws:
This is unsurprising, since the FromSql approach requires the function
Range
to be executed on the client.The second attempt would be with a custom function translation. In this case, I have a static function:
And a function mapping:
If I use this in a query:
This fails with a similar exception:
EF Core version: 2.2
Database provider: Microsoft.EntityFrameworkCore.Oracle
Target framework: .NET Framework 4.7
Operating system: Windows 10
IDE: Visual Studio 2017 15.8.6
The text was updated successfully, but these errors were encountered: