title: LINQ to Entities does not recognize the method
body: <p>I am following <a href="http://msdn.microsoft.com/en-us/library/ff714955.aspx" rel="nofollow">this article</a> on MSDN. I ported it to EF Code First.</p>
  
  <pre><code>public interface IUnitOfWork
  {
      IRepository&lt;Employee&gt; Employees { get; }
      IRepository&lt;TimeCard&gt; TimeCards { get; }
      void Commit();
  }
  </code></pre>
  
  <hr>
  
  <pre><code>public class HrContext : DbContext
  {
      public DbSet&lt;Employee&gt; Employees { get; set; }
      public DbSet&lt;TimeCard&gt; TimeCards { get; set; }
      protected override void OnModelCreating(ModelBuilder modelBuilder)
      {
          modelBuilder.Entity&lt;Employee&gt;()
                      .HasMany(e =&gt; e.TimeCards)
                      .WithOptional(tc =&gt; tc.Employee);
       }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>public class SqlRepository&lt;T&gt; : IRepository&lt;T&gt;
      where T : class
  {
      private readonly DbSet&lt;T&gt; entitySet;
      public SqlRepository(DbContext context)
      {
          this.entitySet = context.Set&lt;T&gt;();
      }
      public void Add(T newEntity)
      {
          this.entitySet.Add(newEntity);
      }
      public IQueryable&lt;T&gt; FindAll()
      {
          return this.entitySet;
      }
      public T FindById(params object[] keys)
      {
          return this.entitySet.Find(keys);
      }
      public IQueryable&lt;T&gt; FindWhere(Expression&lt;Func&lt;T, bool&gt;&gt; predicate)
      {
          return this.entitySet.Where(predicate);
      }
      public void Remove(T entity)
      {
          this.entitySet.Remove(entity);
      }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>public class SqlUnitOfWork : IUnitOfWork, IDisposable
  {
      private readonly HrContext context;
      private IRepository&lt;Employee&gt; employees;
      private IRepository&lt;TimeCard&gt; timeCards;
      public SqlUnitOfWork()
      {
          this.context = new HrContext();
      }
      public IRepository&lt;Employee&gt; Employees
      {
          get
          {
              return new SqlRepository&lt;Employee&gt;(context);
          }
      }
      public IRepository&lt;TimeCard&gt; TimeCards
      {
          get
          {
              return new SqlRepository&lt;TimeCard&gt;(context);
          }
      }
      public void Commit()
      {
          this.context.SaveChanges();
      }
      public void Dispose()
      {
          context.Dispose();
      }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>var query = from e in unitOfWork.Employees.FindAll()
              from tc in unitOfWork.TimeCards.FindAll()
              where tc.Employee.Id == e.Id &amp;&amp; e.Name.StartsWith("C")
              select tc;
  var timeCards = query.ToList();
  </code></pre>
  
  <p>This model is great as it gives me testability. However, running queries like the one above throws this </p>
  
  <pre><code>LINQ to Entities does not recognize the method
   'System.Linq.IQueryable`1[DomainModel.Models.TimeCard] FindAll()' 
    method, and this method cannot be translated into a store expression.
  </code></pre>
  
  <p>I understand the error but is there any way to avoid it but still keep the repositories for testability?</p>