Query over multiple entities using the same interface [Answered]
I have a EF setup, where ~20 entities implement
IArchivable
This interface has a public
I wish to perform a query to find the entity with a certain id, and then another query to set the IsArchived
property to false
.
Is this possible with EF? (something like _context.Set<IArchivable>().Where(...)
Or should I loop through all types (using reflection) and build an IQueryable for each of them?7 Replies
You can't have full lambda bodies in EF right?
Pissed me off last time I worked with it too
yeah no full lambda bodies, but you can do a whole lot with expressions
If you can, you'd do
Don't know if possible with expressions
let me try if the .Set<Interface> works
I think I tried it and it didn't, but I should try again
Ah, that part wasn't already correct?
Don't know the answer on that one
I'm going for something like this now
let's test if it works
✅ This post has been marked as answered!