开发者

Convert a lambda to a dotted string e.g. x => x.Address.City becomes Address.City

I want to convert a lambda expression referencing a property or sub-property of an o开发者_JS百科bject, 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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜