-
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
Compiled model: Generate code for query filters when possible #24897
Comments
Would be interested to know if you have a rough idea of what sort of query filters you might be able to generate code for? Just to get an idea if our model with query filters is likely to be supported in future. The filters are like |
Note from triage: consider encapsulating filter in a type as a way of not needing the expression tree to be contained in the model. |
It would be awesome to get more compiled models features in EF 8, this one is in particular since query filters are quite useful, so I tend to use them a lot |
Is there a workaround for this in the interim, i.e. is there a way to use compiled models together with global query filters even if code for query filters is not currently generated? The original post refers to avoiding the need for "post-processing", but I'm not sure what this is referring to. (I always use soft delete filters, so haven't been able to take advantage of compiled models to date.) |
@zejji I don't believe there is any workaround for this. |
We are add globle filter. In Function CreateAnnotations of file EntityType
can i use it like this? |
@truonghoangsw Yes, that should work as long as the filter doesn't have to reference the |
Would be very nice for ef core 9! Most of the time we would want to use it for multi tenancy and soft deleting |
Unfortunately there is no clear scope defined for what "when possible" means, so these scenarios might not be supported. |
truonghoangsw's comment seems to work no? |
Yes,it work |
I suppose that this issue is about the limitation of using global query filters in combination with compiled models. The original announcement states that it is not possible to use compiled models with global query filters. Is this still the case? I'm unable to find any first party documentation about compiled models. I would like to use compiled models with global query filters. Currently we are using them to filter out soft deleted entities. Some comments here mention that this is possible. Is this the case? |
@klemmchr Yes, as a workaround you can remove the global filter, generate a compiled model and then manually edit it to add the filter as seen in #24897 (comment) |
Would this change be persisted between model updates and recompilations or do I need to add this manually every time after compiling? |
You'd need to do it every time you regenerate the model. |
You can do it in the Customize partial method in a separate file. Compiled model EntityType classes are all partial |
Avoid the need for post-processing for relational providers
The text was updated successfully, but these errors were encountered: