That's because you need to pass the paymentAttempt
object to your context, to let it know that it is an object that needs to be updated.
For example, assuming that _auctionContext
is an instance of DbContext
:
// any changes related to the paymentAttempt object
_auctionContext.Entry(paymentAttempt).State = EntityState.Modified;
foreach (var winningBid in relevantWinningBidsTotalPrices)
{
winningBid.Locked = false;
_auctionContext.UpdateObject(winningBid);
}
_auctionContext.SaveChanges();
Another option is the Attach
method:
_auctionContext.Attach(paymentAttempt);
_auctionContext.ObjectStateManager.ChangeObjectState(paymentAttempt, System.Data.EntityState.Modified);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…