0
想知道是否有人可以看到爲什麼我收到錯誤「行未找到或更改。」當我執行這個LINQ查詢。爲什麼我的Linq查詢不更新數據庫?
行在那裏,數據正在拾取好,但是當涉及到更新時,我得到了上面提到的錯誤。
aboDataDataContext dc = new aboDataDataContext();
var orders = dc.GetOrderToAcknowledges;
//Get the TWE Order ID and Store in DB.
foreach (var order in orders)
{
int orderId = dc.amzOrders.Single(o => o.amzOrderId == order.amzOrderId).id;
DateTime now = DateTime.Now;
GetTWEOrderID(orderId, now.ToString());
amzOrder orderUpdate = dc.amzOrders.Single(o => o.id == orderId);
orderUpdate.acknowledged = true;
orderUpdate.lastUpdate = Convert.ToDateTime(now);
dc.SubmitChanges();
}
可能重複[Linq的行未找到或改變(HTTP:// stackoverflow.com/questions/8851482/linq-row-not-found-or-changed) –
你在上下文dc中做過其他任何事情嗎? – DaveHogan
yes會更新上面的代碼... – thatuxguy