I have a web application where users are allowed to love objects. Each item has the property of everything that he received.
The problem arises when many users like the same element at the same time, then I get the wrong values in SQL (caused by the race condition).
As a temporary solution, I created a workflow in the controller’s constructor, which works against the queue, when it receives a request like / dislike, I execute a queue with this request. The workflow deactivates the values and updates the dictionary that maps itemid to totalcount.
The workflow then updates the database once every minute with the result.
Side question: context.SaveChanges()to save only what has changed in the object? Or does it save all the properties of objects?
I have a feeling that this solution is not right, what is the best way to deal with such a problem?
source
share