Is the Expression in an HtmlHelper For method's signature solely for type checking the View?

51 Views Asked by At
expression
Expression<Func<TModel,TProperty>>
An expression that identifies the object that contains the properties to display.

DropDownListFor<TModel,TProperty>(HtmlHelper<TModel>, 
Expression<Func<TModel,TProperty>>, 
IEnumerable<SelectListItem>, String, IDictionary<String,Object>)

It is here.

Is the Linq Expression there solely for the View and compilation or other typing needed in ASP.NET MVC? I know what TModel is, but TProperty doesn't really show me much in Visual Studio. SelectListItem and the rest are self-explanatory.

I am confused because of this SO question.

Difference between DropDownlist or DropDownListFor Html helper

It seems it is for that and more, but I am not sure. This is more of a question on how to read the signature in Microsoft's Documentation and its implications. Sometimes is seems the Expression is for the View and doesn't really mean too much in the SelectList as people pass in the ViewBag with elements for Value and Text. Other times is looks like it actually contributes to what something displays, like in DropDownDisplayFor.

0

There are 0 best solutions below