-
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
How to configure an entity property's generated sql to be a subquery or call to UDF? #27482
Comments
Note for triage: see #10768. |
Why was this closed? The referenced issue doesn't solve this. |
The translation requirement in #10768 is similar to what you are looking for. Why do you say it wouldn't apply for your scenario? |
@AndriySvyryd Thanks for your response.... I'll try to explain further what I'm running up against. I'm using an open source framework that internally calls the Is there a way to define the sample I gave above:
I've looked at overriding the Set method in the DbContext, but FromRawSql() returns an IQueryable rather than DbSet |
There's currently no way of doing something like that, but #10768 should make it possible.
If you don't control the query creation then the used id would need to be injected at the model level. |
Given the following entity model, is there a way I could instruct/configure the EntityQueryProvider to generate a parameterized subquery or call to a UDF in place of a column name?
By default, the generated SQL would look something like this:
But I'd like to have alternate SQL generated for the DisplayName: (where "211" is dynamically passed in from calling code)
I've successfully tried using FromSqlRaw(), but not sure how to do something like this for when Plans are "Included" in another associated DBSet, such as:
DbContext.Users.Include(nameof(Users.Plans))
Is there was a way to do this at field level configuration, rather than the entire entity level? Or at a global level once that applies to all calls to Plans?
NOTE: The particulars of the requirements, constraints, in addition to our use of a framework that builds dynamic queries onto the default Set at runtime that would no longer be useful with any other approach. Additionally, the results requires a sort by DisplayName and will be delivered in pages of results - not the entire result set.
EF Core version: 3.1
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 3.1
Operating system:
IDE: Visual Studio 2019 16.3
The text was updated successfully, but these errors were encountered: