I think I use TPT inheritance. I have an abstract parent class and three subclasses. What I want is a basic find function, but I need to explicitly do includes. My problem is how can I include different properties based on the type.
public List<RandomObject> FindAll(int someProperty)
{
using (MyContext db = new MyContext())
{
var randomObjects = db.RandomObjects.Where(x => x.SomeProperty == someProperty);
}
}
Each instance of RandomObject has a collection of the abstract Superclass. There are a fixed number of known subclasses (we can call them SubclassA and SubclassB if people need names).
I have been trying various Include statements such as this
randomObjects = randomObjects.Include(x => x.Superclasses.OfType<SubclassA>().SubclassAOnlyProperty);
If there is any clarification needed just let me know, I could definitely fill this post with all sorts of things I have tried.