title: ORM Repository Pattern
body: <p>This is more of a question where I am looking for opinions.  I am working on a project that uses both NHibernate and EntityFramework (this is by design, wanted flexibility).  So, I went ahead and started working on a Repository pattern, but came across a slight dilemma.</p>
  
  <p>Basically, I wanted to know what you guys think about the following areas:</p>
  
  <ol>
  <li><p>Should the Repository be a singleton? - This will allow me to keep the sessions opened, but at the same time, I think it's going to keep connections opened to the database.  For NHibernate, the ORM can only gurantee an objet is the same within the same session.  This is ideal for easy coding, but there are definatly ways to overcome this using keys and overriding the GetHashCode and Equals methods.</p></li>
  <li><p>If it's not a singleton (or even if it is), should I be closing the connections as soon as they are used?  For NHibernate, that means closing the session each time the Repository is "Disposed", which is after every use.</p></li>
  <li><p>Have you implemented a Repository pattern for either NHibernate or EF 4.0 and found any useful ideas?</p></li>
  </ol>