title: Linq to SQL a good way to lock table
body: <p>I have a method that checks if a certain record (with some id) in the database exists. If it does, it gets updated and if it does not, it gets created. This method is called from ASP.NET Web API so there can be many concurrent calls.</p>
  
  <p>Now I use a classic .NET lock at the start of the method. It works but the performance is really poor (as expected, locking the whole method). Most of the request are not in conflict, working with different records.</p>
  
  <p>Is there a better way to do it better utilizing Linq to SQL that I use? </p>