Kamyar is right, there is no way to do this because, as you yourself told us
i will always have an Animal object coming out of my database like that
so you need to save the type also in your database
after that you should change Animal to
public class Animal { public long Id { get; set; } public string Name { get; set; } public string AnimalType { get; private set; } public Animal() { } public Animal(string type) { AnimalType = type; }
.
Dog doesnt have any more parameters than Animal has, only new methods
so you can change your Dog to
public class Dog : Animal { public Dog(Animal a) { base.set(a); } public void sniffBum() { Console.WriteLine("sniff sniff sniff"); } }
.
i could just create a new Dog object, and pass the values accross, (...), but this just seems messy
I don’t think there is a way and it doesn’t look dirty
and here how to use an example
Animal a = new Animal("Dog"); if (a.AnimalType =="Dog") { Dog d = new Dog( a); d.sniffBum(); }
source share