title: When should i be opening and closing MongoDB connections?
body: <p>i am very new to MongoDB and NoSQL in general and i've just started building a site with MongoDB / Norm / ASP.NET MVC 3.</p>
  
  <p>I am wondering how i should be scoping the connections to my Mongo database.</p>
  
  <p>Right now i have a Basecontroller that instanciates the MongoSession and onActionExecuted i dispose it so all my deriving controllers will have access to my MongoSession. The MongoSession class opens a connection in its constructor and disposes it on Dispose(), the way it's working today.</p>
  
  <pre><code>private IMongo _mongo;
  
  public MongoSession()
  {         
      _mongo = Mongo.Create("connString");      
  } 
  
  public void Dispose()
  {
      _mongo.Dispose();
  }
  </code></pre>
  
  <p>I am a bit worried it might be holding connections open too long if i am doing other stuff aswell in the controllers.</p>
  
  <p>Is that approach enought to not risking holding too many connections open or should i be doing something more like the example method below? </p>
  
  <pre><code>   public void Add&lt;T&gt;(T item) where T : class, new()
     {
         using (var mongo = Mongo.Create("connString"))
         {
           mongo.GetCollection&lt;T&gt;().Insert(item); 
         }
     }
  </code></pre>
  
  <p>Another follow up question is:</p>
  
  <p>Are opening and closing MongoDB connections through Norm "expensive" operations?</p>