title: Making access to db static = bad?
body: <p>In a couple of .NET C# webservice projects that i have done i have made access to db static with help of the singleton pattern. Then the other day my friend told me that this is a bad thing to do, because if a lot of request is made for the same db entity then the db would be locked because of the static instance. Is my friends assumptations right? I thought that every new request would make a new instance of the class?</p>
  
  <p>The implementation of the singleton class looks like this:</p>
  
  <pre><code>public class WebService
  {
      private readonly IFactory _factory;
  
      public WebService(IFactory factory)
      {
          _factory = factory;
      }
  
      public IDataRepository Data
      {
          get
          {
              return _factory.GetDatabase();    
          }            
      }
  }
  
  public static class WebServiceImpl
  {
      private static readonly WebService _webService = new WebShop(new WebserviceFactoryImpl());
  
      public static WebService webService { get { return _webService; } }
  
  }
  </code></pre>
  
  <p>_factory.GetDatabase() returns a new instace of the Database class.</p>