I am using the EF-Core and have a data model like that (just an example with the animal to keep things simple). The inhertitance is mapped in the database via TPT (table per type).
public abstract class Animal { }
public class Monkey : Animal { }
public class Bear : Animal { }
public class Dog: Animal { }
On my frontend I am displaying all animals. So I create a query of the base-type (abstract) and display all animals on the frontend. But now I want to add a filter via query-string to only display a certain type-set of animals (e.g. Dog and Monkey).
What's the best practice to do so?
With TPT unfortunately I don't have no discriminator to have a handle to filter? How is this done?
Currenty I am receiving the selected types in my WebApi-Conroller via a string array, e.g:
public IActionResult(string[] types) {
// ...
}
An idea would by to map this string array to Type and then go with .OfType. But then I have the problem that I am not able to chain OfType, because the result-set is always ZERO when chaining.
And it would be perfect that the filtering is done on the database directly, so I want to avoid to that in memory for performance reasons.
Any ideas?