-
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
Query: Model-level filters for queries #5774
Comments
Agreed the idea of a global filter would be useful. Popping on the backlog as it is lower priority than some things we are going to tackle first. BTW we have an issue specifically for soft delete (#4025), but we also want to track this more general idea. Regarding EntityFramework-Plus, we have #3736 on our candidate list to address in the 1.1.0 release. |
oh what a coincidence that you commented on this just a few minutes ago! I"m trying to use an interface in onmodelcreating and have been looking for workarounds to the requirement that modelbuilder.Entity requies a reference type and won't accept an interface. Any temporary workarounds that you know of? Thanks |
this is my sad little magic string, not type-checked, workaround:
modelBuilder.Entity().Ignore(p=>p.thenonmappedproperty) But okay for my purposes for the time being. :) |
Hy guys, thx for the infos and hints. My focus isn't on the softdeletion topic, it's more an example of a usecase (like DateCreated/DateModified) for the Filter request. I've got a working softdeletion implementation by overwriting OnSaveChanges now, but since you both are referring to the shadow properties, i'm wondering if shadow props would be a 'cleaner' approach than overwriting OnSaveChanges. As I understand the Pros for "shadow props" over "OnSaveChanges Overwriting" would be, that i don't have to implement the same interface on every model, and would have still access to the properties over the "not type-checked" way, as @julielerman describes it in her last comment. So the "not type-checked" way would in that aspect still be a little Con over the "OnSaveChanges" approach. @julielerman I grew fond of your pluralsight vids the last half year, and so I'm wondering to which approach your experienced guts feeling would tend to? Edit: Decided to go with Shadow Props, because "DateModified" alike props would get included each time in default scaffolding scenarios. (when not exluding them especially or using custom scaffolding libs) |
Addressed in b1379b1 |
Is there any documentation for that? |
To clarify, the filters are also applied to types deriving from |
@hikalkan we still have a lot of work to do in documenting 2.0 features. There is a simple example in the announcement blog post. @HappyNomad that is correct. The only limitation AFAIK is that the filter can only be defined over the base type on a hierarchy. |
Do shadow properties work in this context? I'd like to write:
If not, where's the issue for this or do I need to create it? |
@HappyNomad Yep, that should work. |
Moved to #10117. |
If that filter is not using navigation path then it would just work. |
Hy there, hope you're all doing well. ;)
This is a Feature Request.
I was wondering, if EF Core will support/implement a Filtering functionality for e.g. SoftDeletion configurable in a
CustomDbContext.OnModelCreating(ModelBuilder builder)
like this:builder.Filter<IBaseEntity>(e => e.Where(x => !x.IsSoftDeleted));
Whereas
IBaseEntity
Interface ensures that the concerned models have theIsSoftDeleted
property.In addition it would also be nice, if this filter could be
turned on and off
, if e.g. i would need to access the deleted records for administration/historyview purposes.There is a library from zzzprojects EntityFramework-Plus that would support this in older versions of EF, but it would be nice, if the desired functionality would be working out of the box/native, without using that library.
The creators of EntityFramework-Plus note on their page, that
So i'd like to know, if we can expect this feature to be built in on 1.0.0 (Tools Preview 2) Milestone at 27 June 2016, or if this bug will be looked at, so that zzzprojects could bring out a new version of their libraries.
Please let me know what your plans are concerning that topic, I hope I'm not the only one, that would love that feature, otherwise i would probably have to do that filtering manually in all my Repositories/DAL.
Kind regards
Adrian
The text was updated successfully, but these errors were encountered: