更新代码中的多个表关系 [英] update multiple table relation in code
本文介绍了更新代码中的多个表关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
i需要在三个表之间更新多对多的关系
员工和课程以及员工课程
当表employeecourse中的更新课程ID未完成时b
我的模型customemployee2
namespace WebCourse.Models {
i need to update relation many to many between three tables
employee and courses and employeecourses
when update course id in table employeecourse not done
my model customemployee2
namespace WebCourse.Models {
public class Customemployee2
{
public string Name { get; set; }
public int Salary { get; set; }
public string Email { get; set; }
public int DistrictId { get; set; }
public int CourseId { get; set; }
public IEnumerable<SelectListItem> Districts { set; get; }
public List<EmployeeCourse> Courses { get; set; }
public List<EmployeeLangage> Langs { get; set; }
} }
[HttpPost]
public ActionResult Edit(int id,Customemployee2 cust2)
{
Employee old = db.Employees.Find(id);
if (old != null)
{
old.Name = cust2.Name;
old.Email = cust2.Email;
old.DistrictId = cust2.DistrictId;
old.Salary = cust2.Salary;
//what i write here to update courseId in employeecourse where select course id
db.SaveChanges();
return RedirectToAction("Index");
db.Employees.Include
}
return View(cust2);
}
如何更新表employeecourse中的courseid
how to update courseid in table employeecourse
推荐答案
你能帮助我吗
这篇关于更新代码中的多个表关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文