将RouteValueDictionary转换为匿名对象的快速方法?

Mat*_*nig 6 .net asp.net-mvc-3

我有一个MVC3 RouteValueDictionary,我想快速转换为匿名类型.

例如:

new RouteValueDictionary(){{"action","search"}}
Run Code Online (Sandbox Code Playgroud)

会是一样的

new {action="search"}
Run Code Online (Sandbox Code Playgroud)

Mar*_*ade 6

这在运行时是不可能的.需要在编译时预先知道匿名类型的属性.