有人可以解釋如何有條件地從EF結果集中刪除對象嗎?循環中的條件記錄刪除
這裏是我的代碼
var newClubKitOrders = from q in db.NewClubKitOrders where q.NewClubId == ncbId select q;
if (newClubKitOrders.Any())
{
foreach (NewClubKitOrder order in newClubKitOrders)
{
if (checkedStatus == true)
{
order.OrderDate = DateTime.Now;
}
else
{
//delete the row (order.delete())
}
}
newClubKitOrders.SaveChanges();
}
感謝
http://stackoverflow.com/questions/17723626/entity-framework-remove-vs -deleteobject –
有什麼問題?刪除方法,循環? –