Asp.net mvc 所有操作完成后,最后保存数据

Asp.net mvc 所有操作完成后,最后保存数据,asp.net-mvc,public,actionresult,Asp.net Mvc,Public,Actionresult,嗨,请帮助我,我有5个模型,我想一次保存所有模型,所以请帮助我 我的模特是 public partial class EmployeeMainTable { public EmployeeMainTable() { this.employee_DepartmentTable = new List<EmployeeDepartmentTable>(); } public int Emp

嗨,请帮助我,我有5个模型,我想一次保存所有模型,所以请帮助我

我的模特是

public partial class EmployeeMainTable
    {
        public EmployeeMainTable()
        {
            this.employee_DepartmentTable = new List<EmployeeDepartmentTable>();
        }



        public int EmployeeId { get; set; }

        [Required(ErrorMessage = "Enter the Name")]
        public string EmployeeName { get; set; }

        [Required(ErrorMessage = "Enter date of joining")]
        [DataType(DataType.Date)]

        public System.DateTime EmployeeDateOfJoining { get; set; }

        [Required(ErrorMessage = "Department Required")]
        public int EmployeeDepartmentId { get; set; }

        [Required(ErrorMessage = "Designation Required")]
        public int EmployeeDesignationId { get; set; }

        [Required(ErrorMessage = "Location Required")]
        public int EmployeeLocationId { get; set; }

        [Required(ErrorMessage = "Employee status Required")]
        public int EmployeeStatusId { get; set; }

        [Required(ErrorMessage = "Employee Type Required")]
        public int EmployeeTypeId { get; set; }

        [Required]
        public bool EmployeeIsActive { get; set; }

        [Required(ErrorMessage = "Confirmed Date Required")]
        [DataType(DataType.Date)]
        public DateTime EmployeeConfirmDate { get; set; }

        [Required(ErrorMessage = " Email required")]
        [RegularExpression(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*", ErrorMessage = " Must be a valid e-mail address ")]
        public string EmployeeEmailId { get; set; }

        [Required(ErrorMessage = "Contact Number Required")]
        public string EmployeeContactNumber { get; set; }

        [Required(ErrorMessage = "Date of Birth Required")]
        [DataType(DataType.Date)]
        public DateTime EmployeeDateOfBirth { get; set; }


        public ICollection<EmployeeAssetsTable> employee_AssetsTable { get; set; }
        public  List<EmployeeDepartmentTable> employee_DepartmentTable { get; set; }
        public ICollection<EmployeeDesignationTable> employee_DesignationTable { get; set; }
        public ICollection<EmployeeEducationDetailTable> employee_EducationTable { get; set; }
        public ICollection<EmployeeFamilyTable> employee_FamilyTable { get; set; }
        public ICollection<EmployeeLocationTable> employee_LocationTable { get; set; }
        public ICollection<EmployeeStatusTable> employee_StatusTable { get; set; }
        public ICollection<EmployeeTypeTable> employee_TypeTable { get; set; }

        public virtual ICollection<EmployeePreviousCompanyDetailTable> employee_PreviousCompanyDetailTable { get; set; }
        public virtual ICollection<EmployeeDocumentsTable> employee_DocumentTable { get; set; }
公共部分类EmployeeMainTable
{
公共雇员主表()
{
this.employee_DepartmentTable=新列表();
}
public int EmployeeId{get;set;}
[必需(ErrorMessage=“输入名称”)]
公共字符串EmployeeName{get;set;}
[必需(ErrorMessage=“输入加入日期”)]
[数据类型(DataType.Date)]
public System.DateTime EmployeeDateOfJoining{get;set;}
[必需(ErrorMessage=“部门必需”)]
public int-EmployeeDepartmentId{get;set;}
[必需(ErrorMessage=“指定必需”)]
public int EmployeeDesignationId{get;set;}
[必需(ErrorMessage=“位置必需”)]
public int EmployeeLocationId{get;set;}
[必需(ErrorMessage=“必需的员工状态”)]
public int EmployeeStatusId{get;set;}
[必需(ErrorMessage=“必需的员工类型”)]
public int EmployeeTypeId{get;set;}
[必需]
public bool EmployeeIsActive{get;set;}
[必需(ErrorMessage=“需要确认日期”)]
[数据类型(DataType.Date)]
公共日期时间EmployeeConfirmDate{get;set;}
[必需(ErrorMessage=“电子邮件必需”)]
[正则表达式(@“\w+([-+.]\w+*@\w+([-.]\w+*\)。\w+([-.]\w+*”,ErrorMessage=“必须是有效的电子邮件地址”)]
公共字符串EmployeeEmailId{get;set;}
[必需(ErrorMessage=“必需的联系电话”)]
公共字符串EmployeeContactNumber{get;set;}
[必需(ErrorMessage=“必需的出生日期”)]
[数据类型(DataType.Date)]
公共日期时间EmployeeDateOfBirth{get;set;}
公共ICollection employee_资产表{get;set;}
公共列表员工_部门表{get;set;}
公共ICollection employee_指定表{get;set;}
public ICollection employee_EducationTable{get;set;}
公共ICollection employee_FamilyTable{get;set;}
公共ICollection employee_LocationTable{get;set;}
公共ICollection employee_StatusTable{get;set;}
公共ICollection employee_TypeTable{get;set;}
公共虚拟ICollection employee_PreviousCompanyDetailTable{get;set;}
公共虚拟ICollection employee_DocumentTable{get;set;}
同样,我有5个模型


我需要的是,我需要将模型从一个动作切换到另一个动作,如果我在最后一节中单击“提交”按钮,那么数据将立即从所有模型中保存

如果我理解正确,您就不能在模型2中为模型1设置一个属性,在模型2和模型3中设置一个属性,以此类推

或者使用定制的ViewModels来满足您的需求

我刚开始使用MVC,所以这是我的新手建议,不要想当然