public class Model1 {
public String Value { get; set; }
}
public class Model2 {
public dynamic Value { get; set; }
}
public static Expression<Func<Model2, Model1>> GetExpression() {
return f => new Model1 {
Value = f.Value
};
}
I am writing a GetExpression()
which convert Model2
property to Model1
. When it comes to dynamic property, I try Convert.ToString(f.Value)
or (String)f.Value
but it said
"An expression tree may not contain a dynamic operation"
Anyone know what is the proper way to convert dynamic value to type value in expression?