I'm trying to create the expression in this method dynamically:
myObject.myMethod(x=>x.Property);
Instead of specifying the Property at design time I'm trying to specify it at runtime
PropertyInfo pInfo=template.GetType().GetProperty("myProperty");
myObject.myMethhod(x=>Expression.MakeMemberAccess(Expression.Parameter(x.GetType(), "t"), pInfo).Expression);
But that doesn't work. Is there a way to do it?
Aucun commentaire:
Enregistrer un commentaire