Generics w/ EF Core
I have an API that I don't control that looks something like this:
I want to be able to create and store
Filter
objects in my database:
However, when trying to use generic methods, I can't access the DbSet
for the particular filter that I need:
Basically, I want to easily be able to retrieve (or add) the appropriate Filter
from my database, while keeping my various methods generic2 Replies
are you looking for
if (typeof(T) == typeof(A))
?maybe consider TPH as well https://learn.microsoft.com/en-us/ef/core/modeling/inheritance#table-per-hierarchy-and-discriminator-configuration
Inheritance - EF Core
How to configure entity type inheritance using Entity Framework Core