我正在使用實體框架和工作單元。如何使用實體框架和工作單元自行更新數據庫級別的列?
我在Person
表中有一個小數列OrderBalance
,我有一個Order
表。我想在db級自己更新orderbalance
列以支持併發訂單創建。
我想插入訂單並更新OrderBalance
列與atomocity(全部或全部)。
public override void Create(Order order)
{
_orderReposiory.Add(order);
var person = _personRepository.GetById(order.PersonId);
person.OrderBalance += order.Amount*order.Price;
_personRepository.Edit(person);
_unitOfWork.Commit();
}
正如您所看到的,'+ ='進程位於對象級別。我如何在不破壞原子性的情況下在db級別上執行此操作?