I'm have used WCF services before, and now I have a new project coming up. I am still in the design phase, and I wondered what the best way to handle the following scenario.
I will be having multiple clients connecting at the same time to my WCF service, firing different methods (Operation Contracts) on the service :
A. Some of the methods fired are just pure 'Read' methods (e.g. GetListOfCustomers).
B. Some are the methods fired are complex 'Read' methods (e.g. GetAllProductsByCustomerId). These kind of methods require getting the customer from the DB, checking something on him, and then getting all the products bought by him. (meaning, there are 2 calls to the database in this method).
C. Some are 'Write' methods (e.g. 'RemoveCustomer' or 'SetProductOutOfStock').
My question is - how do I synchronize all these calls so that I don't get concurrency problems?
I don't want the entire service to process calls serially, because it will damage performance on the client side (some calls may require 3-4 seconds to process). So what is my solution ?
Use a 'Single' instance for all clients with 'Multiple' threads and then use a lock object ? Won't this just result to being serial ?
Or do I need a different lock object for the 'read' and a different lock object for the 'write' ?
Or do I need a lock for the 'write' functions and some other thing for the 'read' functions ?
This is my first question ever on StackOverflow. Thanks for anyone who can help !
Update : I am going to use 'Linq-To-SQL' as my ORM.