get value of a property o => o.Property1 , defined in lambda
- by Omu
I need to get the value of a property defined in a lambda
public static MvcHtmlString MyHelper<T, TProperty>(
this HtmlHelper<T> html,
Expression<Func<T, TProperty>> prop)
{
var value = \\ get the value of Prop1 (not the name "Prop1")
...
}
the intended usage is something like:
public class FooViewModel
{
public string Prop1 { get;set; }
}
<%@ Page ViewPage<FooViewModel> %>
<%=Html.MyHelper(o => o.Prop1) %>