title: Using nHibernate and the repository pattern, need some direction
body: <p>Ok so I 'm just getting into nhibernate (using fluent).</p>
  
  <p>One thing that I love about it is that I can use the Repository pattern (read about it from the nhibernate rhino blog).</p>
  
  <p>Basically using generics, I can create methods that will work accross ALL my database tables.</p>
  
  <pre><code> public interface IRepository&lt;T&gt;
      {
          T GetById(int id);
          ICollection&lt;T&gt; FindAll();
          void Add(T entity);
          void Remove(T entity);
      }
  
  
   public class Repository&lt;T&gt; : IRepository&lt;T&gt;
      {
  
          public ISession Session
          {
              get 
              { 
                  return SessionProvider.GetSession(); 
              }
          }
  
  
          public T GetById(int id)
          {
              return Session.Get&lt;T&gt;(id);
          }
  
          public ICollection&lt;T&gt; FindAll()
          {
              return Session.CreateCriteria(typeof(T)).List&lt;T&gt;();
          }
  
          public void Add(T t)
          {
              Session.Save(t);
          }
  
          public void Remove(T t)
          {
              Session.Delete(t);
          }    
  
      }
  </code></pre>
  
  <p>I then inherit the Repository class and I can then add methods that are specific to that entity.</p>
  
  <p>When trying to add an Update method, someone mentioned that the Repository pattern is suppose to act on collections?  Am I looking at things incorrectly here?  Why can't I create an update method?</p>
  
  <p>I tried adding a update method, but I'm confused as to how I will handle the session and update the database?</p>
  
  <p>I want a single place for all my database access for each entity, so UserRepository will have all basic CRUD and then maybe some other methods like GetUserByEmail() etc.</p>