Why model => model.Reason_ID turns to model =>Convert(model.Reason_ID)
Posted
by er-v
on Stack Overflow
See other posts from Stack Overflow
or by er-v
Published on 2010-05-29T13:36:58Z
Indexed on
2010/05/29
13:42 UTC
Read the original article
Hit count: 1067
asp.net-mvc-2
|lambda-expressions
I have my own html helper extension, wich I use this way
<%=Html.LocalizableLabelFor(model => model.Reason_ID, Register.PurchaseReason) %>
which declared like this.
public static MvcHtmlString LocalizableLabelFor<T>(this HtmlHelper<T> helper, Expression<Func<T, object>> expr, string captionValue) where T : class {
return helper.LocalizableLabelFor(ExpressionHelper.GetExpressionText(expr), captionValue);
}
but when I open it in debugger expr.Body.ToString() will show me Convert(model.Reason_ID). But should model.Reason_ID. That's a big problem, becouse ExpressionHelper.GetExpressionText(expr) returns empty string. What a strange magic is that? How can I get rid of it?
© Stack Overflow or respective owner