剃刀视图引擎:一个EX pression树不能包含动态操作 [英] Razor View Engine : An expression tree may not contain a dynamic operation

查看:209
本文介绍了剃刀视图引擎:一个EX pression树不能包含动态操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个类似的模式:

public class SampleModel
{
     public Product Product { get; set; } 
}

和我的控制器我得到一个异常试图打印出

And in my controller I get an exception trying to print out

@Html.TextBoxFor(p => p.Product.Name)

异常:EX pression树不能包含动态操作

Exception: An expression tree may not contain a dynamic operation

如果任何人都可以给我如何解决这一问题的一些线索,我真的AP preciate了!

If anyone can give me some clues on how to fix this I would really appreciate it!

推荐答案

在我看来,你有一个类型化的观点。默认情况下,在MVC3 RC剃刀意见类型为动态。但是,lambda表达式不支持动态成员。你必须强类型模型。在你的视图文件的顶部添加

It seems to me that you have an untyped view. By default, Razor views in MVC3 RC are typed as dynamic. However, lambdas do not support dynamic members. You have to strongly type your model. At the top of your view file add

@model SampleModel

这篇关于剃刀视图引擎:一个EX pression树不能包含动态操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆