我想写一个EditorTemplate到一般应用依赖于一个辅助提供使从ViewBag模型和附加数据的逻辑CSS类:使用lambda从剃刀局部视图指定属性的Helper类
@using LSC.DCMP.Web.UI.Helpers
@model String
@ValidationFieldHelper.GetCSSClass(m => Model, @ViewBag.Step)
此相匹配,目前未实现一个辅助类,但具有以下特征:
public static class ValidationFieldHelper
{
public static object GetCSSClass(Func<object, string> func, object step)
{
throw new NotImplementedException();
}
}
当我尝试运行应用程序,它无法编译,出现以下错误:
"Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree type".
我读过lambda语法不完全支持使用Razor模板,所以我不确定如何实现此功能。