title: A Repository Factory Class
body: <pre><code>public enum RepositoryType
  {
      ClinicRepository,
      MedicationRepository,
      PatientRepository,
      TreatmentRepository
  }
  
  public class ObjectFactory&lt;T&gt;
  {
      public static IRepository&lt;T&gt; GetRepositoryInstance(RepositoryType type)
      {
          switch (type)
          {
              case RepositoryType.ClinicRepository:
                  return new what ?;
  
              default:
                  return what ?
          }
      }
  }
  
  public interface IRepository&lt;T&gt;
  {
      void Add(T item);
      void Remove(int id);
      void Update(T item);
      IList&lt;T&gt; GetAll();
      T GetItemById(int id);
  }
  </code></pre>
  
  <p>I'm trying to create a RepositoryFactory class and I copied what I've done so far. Could anyone please help me to figure this out ? I'm stuck !
  Thanks in advance</p>
  
  <p>edit : </p>
  
  <p>I want something like this at the end. Is it possible to make 1 Repository class and implement something like </p>
  
  <p>dc.THATOBJECT.insertonsubmit(item) ?</p>
  
  <pre><code>public class TreatmentRepository : IRepository&lt;Treatment&gt;
  {
      public void Add(Treatment item)
      {
          using (PatientsDataContext dc = new PatientsDataContext())
          {
              dc.Treatments.InsertOnSubmit(item);
              dc.SubmitChanges();
          }
      }
  </code></pre>