Is there anyway to determine if a value is passed as a reference, eg. x.Age or a specific value. eg. 20 like so.
value(x => x.Age)
or
value(x => 20)
Cheers
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If value() takes a Func<,> or other delegate type then you basically can’t tell. The function has been compiled: at best, you can look at the IL using reflection and try to figure it out heuristically.
If value() takes an Expression, then you can walk the expression tree. This could be complicated in the general case, but for simple cases like yours, it would suffice to look for a MemberExpression versus a ConstantExpression.