title: How to synchronize database access in a WCF Service?
body: <p>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.</p>
  
  <p>I will be having multiple clients connecting at the same time to my WCF service, firing different methods (Operation Contracts) on the service :</p>
  
  <p><strong>A.</strong> Some of the methods fired are just pure 'Read' methods (e.g. GetListOfCustomers).</p>
  
  <p><strong>B.</strong> 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).</p>
  
  <p><strong>C.</strong> Some are 'Write' methods (e.g. 'RemoveCustomer' or 'SetProductOutOfStock').</p>
  
  <p>My question is - how do I synchronize all these calls so that I don't get concurrency problems?</p>
  
  <p>I <em>don't</em> 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 ?</p>
  
  <p>Use a 'Single' instance for all clients with 'Multiple' threads and then use a lock object ? Won't this just result to being serial ?</p>
  
  <p>Or do I need a different lock object for the 'read' and a different lock object for the 'write' ?</p>
  
  <p>Or do I need a lock for the 'write' functions and some other thing for the 'read' functions ?</p>
  
  <p>This is my first question ever on StackOverflow.
  Thanks for anyone who can help !</p>
  
  <p>Update : I am going to use 'Linq-To-SQL' as my ORM.</p>