同时删除两条记录时,出现错误“无法删除此对象,因为未在 ObjectStateManager 中找到它”
//下面的代码执行删除操作的时候出现了错误,怎么回事啊?
public static bool DeleteDetail(int id)
         {
             try
             {
                 using (var db = new CRM.DataLayer.CRMDateEntities())
                 {
                     //查询对应的订单明细
                     var whwDetail = from enteroroutdetail in db.EnterOrOutDetail
                                     where enteroroutdetail.warehousewarrantID == id
                                     select enteroroutdetail;//查出来两条记录
                     if (whwDetail != null)
                     {
                         db.DeleteObject(whwDetail);//无法删除此对象,因为未在 ObjectStateManager 中找到它。
                         var result = db.SaveChanges();
                         if (result > 0)
                             return true;
                         else
                             return false;
                     }
                     else
                         return false;
                 }
             }
             catch (Exception)
             {
                 return false;
             }
         }
//没多少积分了,请高手帮忙看看
------解决方案--------------------db.DeleteObject(whwDetail);
没办法一次删除多个,需要取出来,一个一个的删除
------解决方案--------------------使用for循环一个一个的删