I'm trying to use reflection to get the model type. So far I was able to get the type of property. But when I tried to use expression to get model type, I'm getting null reference for that property.
expression is like this,
model => model.property
and in function,
//I'm passing model as a parameter
MemberExpression expBody = expression.Body as MemberExpression;
model.GetType().GetProperty(expBody.Member.Name.ToString()));
Is it possible to do something like this?
MemberExpression expBody = expression.Body as MemberExpression;
expBody.Type.GetProperty(expBody.Member.Name.ToString()));
I tried this, but not working.