Reputation: 5943
How does Microsoft MVC know that the name of the property is "Phone" since we have only the object instance and one of it's properties' value?
<%: Html.TextBoxFor(x => x.Phone) %>
Upvotes: 0
Views: 441
Reputation: 1503300
You haven't got the property's value - you've got an expression tree which tells you how to obtain the value from an item. That expression tree can be analyzed by the framework to find the property name.
Now if it were
<%: Html.TextBoxFor(x.Phone) %>
then that would genuinely be just getting the value... but the lambda expression is being converted into an expression tree by the C# compiler.
Upvotes: 3