Why can't you do this through the public auto property, as shown below. BTW, what you are trying to get is Composition , in which the bar object consists of the foo object. Not sure why you still inherit from foo ?
public class bar : Foo { public int ID { get; set; } public Foo baseinstance { get; set;} public bar(Foo instance) { baseinstance = instance; } }
I'm not quite sure, but from your published code (in particular, below) it seems that you are trying to call the base class constructor initializer or constructor initializer , as you said
I am looking to get a child class created using the parent instance to set all the inherited variables.
public bar(Foo instance) { base = instance; }
In fact, it should be
public bar(Foo instance) : base() {
But what is not required for a constructor without parameters occurs when you create an instance of the constructor of the constructor of children, which will be called, and the base class will be initialized first in order to initialize the base element before the child is initialized.
If you have a parameterized constructor in the database and in the descendant, you can explicitly call the database constructor
Rahul source share