mardi 10 février 2015

Ienumerable of T, T is only available at runtime

I have a method with this signature



public IEnumerable<T> GetAll<T>() where T : new()
{
// Orm Lite Version
return Connection.LoadSelect<T>();

}


At compile time I don't know the Type T. I only know the class name at runtime is it possible to call this method using reflection with something like this?



string TargetTBLName = ...;//TargetTBLName get's it's value at runtime
Type ParentTableClass = Type.GetType(TargetTBLName);
IEnumerable<Type.GetType(TargetTBLName)> test = Repository.GetAll<Type.GetType(TargetTBLName)>();


Any Ideas?






Aucun commentaire:

Enregistrer un commentaire