I have this function that uses Linq expressions:
private Expression GetFieldValueExpression(ParameterExpression parameter, string fieldName)
{
Expression properyIndexExpression = System.Linq.Expressions.Expression.Constant (fieldName, typeof(string));
IndexExpression fieldValueExpression = System.Linq.Expressions.Expression.Property(parameter, "Item", new Expression[] { properyIndexExpression });
return Expression.Property(fieldValueExpression, "Value");
}
The value returned by Expression.Property(fieldValueExpression, "Value") is of type string.
I don’t know how to get it. I know that i must create a lambda and compile it, but i don’t know how.
Thank you for your time.
Perhaps you are looking for code like this:
that code assumes some test classes that look like this (basically the indexer property just returns the input but in upper case – a trivial example but works for testing):