© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
12 replies
Tvde1

Query over multiple entities using the same interface [Answered]

I have a EF setup, where ~20 entities implement
IArchivable
IArchivable

This interface has a public
public Guid Id { get; }
public Guid IsArchived { get; set; }
public Guid Id { get; }
public Guid IsArchived { get; set; }

I wish to perform a query to find the entity with a certain id, and then another query to set the
IsArchived
IsArchived
property to
false
false
.
Is this possible with EF? (something like
_context.Set<IArchivable>().Where(...)
_context.Set<IArchivable>().Where(...)
Or should I loop through all types (using reflection) and build an IQueryable for each of them?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Inject multiple implementations of the same interface
C#CC# / help
4mo ago
❔ Iteration over multiple objects at the same time
C#CC# / help
3y ago
Using multiple RateLimiters correctly. [Answered]
C#CC# / help
4y ago
❔ Using JsonConvert to send over interface
C#CC# / help
3y ago