I want to convert a lambda expression referencing a property or sub-property of an object, e.g. x => x.Address.City into a string Address.City. Is there an existing framework method (MVC, EF, …?) that does this or do I need to roll my own? If the latter, any code out there already that does this?
I want to convert a lambda expression referencing a property or sub-property of an
Share
Yes, MVC has this ability built in. It’s used in the HTML Helpers, which can take an expression and render an
<input name = "Address.City">. Look in ExpressionHelper.cs in the MVC source code.