将模型视图对象传递给业务层

时间:2015-03-18 13:51:14

标签: asp.net asp.net-mvc c#-4.0

我在视图中有一个modelview对象,我想在编译时将它传递给我的业务层中的一个函数,我收到错误:

public static bool CreerNouveauHistoEntity(object model)
{
    bool success = false;
    object var = model.Commentaire; 

}

Commentaire没有定义。

如果我删除了行对象var = model.Commentaire; ,它编译好

我该怎么办?

欢呼声

1 个答案:

答案 0 :(得分:1)

object没有将Commentaire作为财产。

你应该投了它:

var obj = ((YourClass)model).Commentaire;

或定义一个合适的参数:

public static bool CreerNouveauHistoEntity(YourClass model)
相关问题