TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
ahmed salah
NA
530
148.8k
cannot convert from int to Models.employeecourse error
Sep 6 2016 5:31 PM
how to loop and delete record from database in table EmployeeCourse table
this is my code
when itry to delete record from
removedCourseIds collection it give me error
cannot convert from int to Models.employeecourse
[HttpPost]
ic ActionResult Edit(EditEmployeeVm model)
{
var existingCourseIds = db.EmployeeCourses.Where(g => g.EmployeeId == model.Id && g.CourseId!=
null
)
.Select(f => f.CourseId.Value).ToList();
var removedCourseIds = existingCourseIds.Except(model.CourseIds);
//Now loop through these and delete it from db
foreach
(var removedCourseId
in
removedCourseIds)
{
//here error show in variable
removedCourseId and show red line under this variable in line of remove
db.EmployeeCourses.Remove(removedCourseId);
}
db.SaveChanges();
return
View();
}
Reply
Answers (
5
)
Sql to Linq Conversion
I have a model(Participant) containing collection model repr