I need to make multiple insert to multiple table have relation with each other
what i need actually when user click submit
Save the following data
Name,Email,Salary,DistrictId in table Employee
EmployeeId,CourseId in table EmployeeCourse
EmployeeId,LanaguageId,LevelId in table EmployeeLangage
what i write in create function in empcourse controller
my code attached with message
my interface and Relation diagram is

Vinay SinghRank #604 · 4K reputationPosted Aug 20, 2016, 11:45 PM EDT
ahmed salahRank #2,612 · 534 reputationPosted Aug 21, 2016, 7:10 AM EDT
can you help me
what i need actually insert
Save the following data
Name,Email,Salary,DistrictId in table Employee
EmployeeId,CourseId in table EmployeeCourse
EmployeeId,LanaguageId,LevelId in table EmployeeLangage
and write it in Create
http post
Manas MohapatraRank #182 · 13.2K reputationPosted Aug 21, 2016, 8:57 AM EDT
Bikesh SrivastavaRank #108 · 20.3K reputationPosted Aug 21, 2016, 10:21 AM EDT
ahmed salahRank #2,612 · 534 reputationPosted Aug 21, 2016, 10:34 AM EDT
ahmed salahRank #2,612 · 534 reputationPosted Aug 21, 2016, 11:34 AM EDT
ahmed salahRank #2,612 · 534 reputationPosted Aug 22, 2016, 2:31 AM EDT
i try with this :
Employee emp = new Employee();]);DistrictId"]);
emp.Name = form["Name"].ToString();
emp.Salary =Convert.ToInt32(form["Salary"
emp.Email = form["Email"].ToString();
emp.DistrictId = Convert.ToInt32(form["
var coursesId = form["Courses"];
string[] coursesIds = null;
if (coursesId != null)
{
coursesIds = coursesId.Split(',');
}
List courses = new List();
foreach (var item in coursesIds)
{
Empcourse ecour = new Empcourse();
ecour.EmployeeId = emp.Id;
ecour.CourseId = Convert.ToInt32(item);
courses.Add(ecour);
}
// emp.EmployeeCourses=courses
emp.EmployeeCourses=courses;
db.Employees.Add(emp);
db.SaveChanges();
but i face problem in this line
emp.EmployeeCourses=courses;
how to assign list to object
it give me this error
cannot implicity convert convert System.collection.Generic.list to System.collection.Generic.Icollection