title: Implement a generic repository pattern using old ado.net
body: <p>I am trying to implement the repository pattern using ado.net because of platform limitation. </p>
  
  
  
  <pre><code>public interface IGenericRepository&lt;T&gt; : IDisposable where T : class
  {
      IQueryable&lt;T&gt; GetAll();
      IQueryable&lt;T&gt; FindBy(Expression&lt;Func&lt;T, bool&gt;&gt; predicate);
      void Add(T entity);
      void Delete(T entity);
      void Edit(T entity);
      void Save();
  }
  </code></pre>
  
  <p>How to complete the following abstract class...?</p>
  
  <pre><code>public abstract class GenericRepository&lt;C, T&gt; :
      IGenericRepository&lt;T&gt;
      where T : class
      where C : IDbDataAdapter, new()
  {
  
      private C dbDataAdapter = new C();
      protected C DB
      {
          get { return dbDataAdapter; }
          set { dbDataAdapter = value; }
      }
  
      public virtual IQueryable&lt;T&gt; GetAll()
      {
          DataTable dt;
          dbDataAdapter.fill(dt);
          IQueryable&lt;T&gt; query = dt....?;
          return query;
      }
  
      public IQueryable&lt;T&gt; FindBy(System.Linq.Expressions.Expression&lt;Func&lt;T, bool&gt;&gt; predicate)
      {
  
          IQueryable&lt;T&gt; query = dbDataAdapter.???Set&lt;T&gt;???().Where(predicate);
          return query;
      }
  </code></pre>
  
  <hr>
  
  <p><strong>Update:</strong><br>
  I will implement the domain specified repository later by inherent these two interface/class.</p>
  
  <pre><code>public class FooRepository :
      GenericRepository&lt;FooBarEntities, Foo&gt;, IFooRepository {
  
      public Foo GetSingle(int fooId) {
  
          var query = GetAll().FirstOrDefault(x =&gt; x.FooId == fooId);
          return query;
      }
  }
  </code></pre>