I work with a situation when we are dealing with money transactions.
For example, I have a table of user wallets with their balance on this line.
UserId; Wallet Id; Balance
Now on our website and web services, every time a certain transaction occurs, we need to:
- make sure that you have enough funds to complete this transaction:
- subtract transaction costs from the balance sheet.
How and what is the correct way to lock this line / object for the entire period of my transaction?
From what I read, there are some solutions where EF marks an object and then compares this sign when it saves it back to the database, however, what does it do when another user / program has already edited the amount?
Can I achieve this with EF? If there are no other options that I have?
Will a stored procedure call possibly allow me to lock the row correctly so that no one else can access that row on SQL Server while there is a lock in program A?
Zapnologica
source share