Converting a lambda to a dotted line, for example. x => x.Address.City becomes Address.City

I want to convert a lambda expression that refers to a property or sub-property of an object, for example. x => x.Address.Cityto a string Address.City. Is there an existing structure method (MVC, EF, ...?) That does this, or do I need to roll my own? If the latter, is any code out there already doing this?

+3
source share
1 answer

Yes, MVC has this ability. It is used in HTML helpers that can take expression and display <input name = "Address.City">. Take a look at ExpressionHelper.cs in the MVC source code.

+4
source

Source: https://habr.com/ru/post/1771789/


All Articles