我尝试在MVC中构建一个帮助器。我尝试传递这样的参数:
@Html.InputHandler(settings =>
{
settings.Name = "Julio";
settings.Mask = "000-000-000";
settings.visible = false;
settings.Label = true;
settings.htmlAttributes = new { @class="form-control" }
})
我有以下代码来定义参数
public delegate void Action<in T>(T obj);
public class InputSettings : SettingsBase
{
public string Name { get; set; }
public bool Label { get; set; }
public string Binding { get; set; }
public bool visible { get; set; }
public object htmlAttributes { get; set; }
public string Mask { get; set; }
}
问题是我无法从助手传递值
public static MvcHtmlString InputHandler(this HtmlHelper htmlHelper, Action<InputSettings> method)
{
var parameters = method. ???
return new MvcHtmlString("");
}
感谢的!
答案 0 :(得分:0)
为了检索正文(因为当你试图检索它时它会被编译并且JIT被带到一个非常不同的状态),你需要一个CriteriaQuery<Tuple> cq = cb.createTupleQuery();
Root<Parent> root = cq.from(Parent.class);
Join<Parent, Child1> child1Join = root.join("child1");
cq.select(cb.tuple(root.get("description"),
child1Join.get("id"),
cb.count(root.get("number")));
cq.groupBy(root.get("description"),
child1Join.get("id")));
。但是,您无法将lambda语句体转换为表达式树。因此,您可能最好将强类型对象作为Func传递并立即撤回结果。
Expression<Action<T>>