I dynamically create instances of my objects in the custom linq provider I am building using this call:
object result = Activator.CreateInstance(typeof(T));
My T type implements an abstract class that has a constructor to take an instance of another object (T is essentially a wrapper). My question is – is there a way I can explicitly call the non-default constructor so I can get rid of this:
MyEntity entity = result as MyEntity;
if(entity != null)
entity.UnderlyingEntity = e; //where e is what I am wrapping
Yes, just supply the constructor arguments after the
Typeobject, like so: