0
我使用此ActionLink方法来生成方法。向ASP.NET MVC4中的对象routeValues自动添加匿名属性ActionLink
LinkExtensions.ActionLink Method (HtmlHelper, String, String, Object)
索所述第四参数是包含匿名属性,用于路由的Object。
它可以追加/自动添加新的匿名属性到现有的RouteValues是对象吗?
如果是,如何?
让我们假设我有一个方法:
public void Test(ref object currentRouteValues, string newValue)
{
if(!string.IsNullOrEmpty(newValue)){
// add a custom property here to currentRouteValues
// something like: (is wrong but I don't know how to proceed)
currentRouteValues = new { currentRouteValues, myCustoProperty = newValue };
}
}
如何为上述方法自动做到这一点?
谢谢