let's say I have the following code (I need to include this snippet anywhere in a more complex expression).
Type paraType = typeof(MyModel);
var member = paraType.GetMember("BlaBla");
MemberExpression myExp = l.Expression.MakeMemberAccess(incidentParameter, member[0]);
I already know that MyModel has a member called BlaBla. I'm looking for a more elegant way to reflect this already known member.
In the sample I reflect the method by its name "BlaBla" as string and pass the MethodInfo to MakeMemberAccess. But I don't like it because it's error prone to refactoring such as renaming. If anybody (including me) renames the property "BlaBla", he will most probably forget to rename this reflection string as well.
I'm out for something similar to the typeof operator:
typeof(MyClass) -> returns a Type obejct. If I rename "MyClass", I have no problem as the reference will be automatically renamed as well.
regards
Andreas