I Have the full name of a type as string and I would like to use this string to tell type of a generic method. see this
string typeStr ="Dll.NameSpace.MyType";
var list = new List<Dll.NameSpace.MyType>();//should put typeStr here
var result = call.SomeGenericMethod<...>(obj);//should put typeStr here
This answer didn't help me. If you try visiting this other one, it does not satisfy my needs.
EDITS: The generic method I'm trying to call is an extension one. I have unsuccessfully tried the following code,
method
remains null
var result = repo.Get();
Type elementType =
Type.GetType("x2o_Care.Models.ViewModels.PatientViewModel");
MethodInfo method =typeof(AutoMapper.QueryableExtensions.Extensions)
.GetMethod("ProjectTo", new[] { typeof(IQueryable)});
MethodInfo generic = method.MakeGenericMethod(elementType);
var model = generic.Invoke(result.OrderBy(e => true).Take(20), null);