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

passing a modelview object to the business layer

我的视图中有一个模型视图对象,我想在编译时将它传递给我的业务层中的一个函数,但出现错误:

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

}

没有 Commentaire 的定义。

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

我该怎么办?

干杯

object 没有 Commentaire 作为 属性。

你应该施放它:

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

或者定义一个合适的参数:

public static bool CreerNouveauHistoEntity(YourClass model)