从控制器分配给子模型项

时间:2018-01-30 11:51:18

标签: asp.net-mvc entity-framework model

我试图为子模型中的项目分配值,但似乎无法做到这一点。

     var model = new WOLFormViewModel
        {
            LastS= 0,                                    
            Start = sitecustomattributes.Start,
            End = sitecustomattributes.End,
            PrimeSel = false,
            ADFSel = false,
            SupplementarySel = false,
            BondSel = false,
            SheetNo = 0,
            EntryOneModel.Code = 1234                                         

        };

EntryOneModel是WOLFormViewModel中的公共类。

有谁知道为什么我无法将数据分配给EntryOneModel.Code = 1234?

1 个答案:

答案 0 :(得分:0)

var model = new WOLFormViewModel
{
    LastS= 0,                                    
    Start = sitecustomattributes.Start,
    End = sitecustomattributes.End,
    PrimeSel = false,
    ADFSel = false,
    SupplementarySel = false,
    BondSel = false,
    SheetNo = 0,
    EntryOne = new EntryOneModel() { Code = 1234 )                                         
};