How to dynamically use the PropertyType reflection attribute to create a respective typed Function<
- by vsj
I want to use type returned by PropertyType to create a typed function. I found this similiar
http://stackoverflow.com/questions/914578/using-type-returned-by-type-gettype-in-c
but this mentions how to create a list but does not mention how we can create a Func<. Please help me out.
Pseudocode:
PropertyInfo inf = typeof(SomeClass).GetProperty("PropertyName");
Type T=inf.PropertyType;
Expression<Func<SomeClass,T>> le = GetPropertyOrFieldByName<SomeClass, T>("PropertyName");