I’m currently writing a WCF web service that uses LINQ to SQL to fetch work with a SQL database.
I have a Users table that had an integer that stores how many requests to the service the user has done. During testing I’m getting some concurrency probs updating the integer if its being done at the same time.
What would be the best way to handle this? If LINQ detects a conflict, re-fetch the usage counter and retry until it changed?
Any ideas would help.
Don’t update the counter on the client (in the WCF process) but instead update it on the server:
This way you don’t care about other concurent calls, because each call correctly increments the counter with 1. Problem is that LINQ cannot do that, but ultimately you have to use the right tool for the right job (in this case being a straight SqlCommand).