I have a lambda expression like this (x => x.FirstName)
and (x => x.Division.Name)
for the definition Expression<Func<Employee,object>>
Now I would like to collect information from this lambda body like the name and type of FirstName
and the name and type of Division
then Name
, how do I do this?
When I browse the value of the expression at debugging I find properties in the expression Body
that gives this information, but when I try to call these properties at design time I can't find them!
EDIT
The duplicate question answers my question for (x => x.FirstName)
where FirstName
is string
, however while experimenting I found when (x => x.Age)
where Age
is integer
or bool
, the body NoteType
becomes Convert
and the Body
can't get cast to MemberExpression
, how should I deal with this situation?