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
ahmed salahPosted Aug 22, 2016, 6:31 AM
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
ahmed salahPosted Aug 21, 2016, 3:34 PM
ahmed salahPosted Aug 21, 2016, 2:34 PM
Bikesh SrivastavaPosted Aug 21, 2016, 2:21 PM
Manas MohapatraPosted Aug 21, 2016, 12:57 PM
ahmed salahPosted Aug 21, 2016, 11:10 AM
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
}Vinay SinghPosted Aug 21, 2016, 3:45 AM