I want to create a custom method, to be able to call it as
@Html.PaginationFor(o => o.List)
I started looking at reflector, but I don't know exactly what it is doing over there. I tried:
public static MvcHtmlString PaginationFor<TModel, TProperty>(this Html&l开发者_Go百科t;TModel> html,
    Expression<Func<TModel, TProperty>> expression)
{
    var propertyValue = ????????
    return html.Partial("View", propertyValue);
}
How do I extract the property value from the expression to pass as a model of the partial view?
public static MvcHtmlString PaginationFor<TModel, TProperty>(
    this HtmlHelper<TModel> html,
    Expression<Func<TModel, TProperty>> expression
)
{
    TModel model = html.ViewData.Model;
    var metaData = ModelMetadata.FromLambdaExpression(expression, html.ViewData);
    var propertyValue = metaData.Model; // This will be of type TProperty
    return html.Partial("View", propertyValue);
}
public static MvcHtmlString PaginationFor<TModel, TProperty>(this HtmlHelper<TModel> html,
    Expression<Func<TModel, TProperty>> expression) {
    var func = expression.Compile();
    var propertyValue = func(html.ViewData.Model);
    return html.Partial("View", propertyValue);
}
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论