get value of a property o => o.Property1 , defined in lambda
        Posted  
        
            by 
                Omu
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Omu
        
        
        
        Published on 2011-01-10T08:17:59Z
        Indexed on 
            2011/01/10
            8:53 UTC
        
        
        Read the original article
        Hit count: 236
        
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) %>
© Stack Overflow or respective owner