我的更新有问题,它没有错误,但没有更新

时间:2014-07-30 13:07:13

标签: asp.net-mvc

  public void Updateemployee(employeeView model)
        {
            using (var emprep = new employeeRepository())
            {
                var employee= new employee();


                if (emp != null)
                {

                   emp.employee_Name = model.employee_Name;
                    emp.employee_Address = model.employee_Address;
                    emp.Email = model.Email;
                    emp.Contact_No = model.Contact_No;
                    emp.Update(emp);
                }
            }

        }

1 个答案:

答案 0 :(得分:0)

你忘记了id。

public void Updateemployee(employeeView model)
    {
        using (var emprep = new employeeRepository())
        {
            var employee= new employee();


            if (emp != null)
            {
                //here  
                `enter code here`emp=emprep.GetById(model.emp_Id);

                emp.employee_Name = model.employee_Name;
                emp.employee_Address = model.employee_Address;
                emp.Email = model.Email;
                emp.Contact_No = model.Contact_No;
                emp.Update(emp);
            }
        }
    }