DeleteObject method is missing in Entity Framework 4.1

后端 未结 2 580
天涯浪人
天涯浪人 2021-01-15 04:33

This is driving me crazy. I am getting error that

object doesn\'t contain definition for DeleteObject.

Here is my line of code

2条回答
  •  走了就别回头了
    2021-01-15 05:25

      [HttpPost]
            public ActionResult Delete(IEnumerable employeeIdsToDelete)
            {
                var lstemployee = _db.StudentEmployees.Where(x => employeeIdsToDelete.Contains(x.Id));
                foreach (var item in lstemployee)
                {
                    _db.StudentEmployees.Remove(item);
                }
                _db.SaveChanges();
    
                return RedirectToAction("Index");
            }
    

提交回复
热议问题