title: Generic repository for generic base class and query for find by key
body: <p>What I want to do is really simple - I want to create generic repository where generic is generic base Entity where generic on Entity sets type of key. Confuse? Don't be, let's a look at code:</p>
  
  <pre><code>public interface IEntity&lt;TKey&gt;
  {
      TKey Id { get; set; }
      DateTime Create { get; set; }
      DateTime? Storno { get; set; }
  }
  
  public class Entity&lt;TKey&gt; : IEntity&lt;TKey&gt;
  {
      public TKey Id { get; set; }
      public DateTime Create { get; set; }
      public DateTime? Storno { get; set; }
  }
  
  public class Repository&lt;TEntity, TKey&gt; : IRepository&lt;TEntity, TKey&gt; 
      where TEntity : Entity&lt;TKey&gt;
  {
      protected DbContext context;
      protected DbSet&lt;TEntity&gt; database;
  
      public TEntity Find(TKey id)
      {
          //return database.SingleOrDefault(f =&gt; f.Id == id); // &lt;-- Here is how it should look like
          return database.SingleOrDefault(f =&gt; f.Id.Equals(id)); // &lt;-- Here is problem EF cann't work with this construction
      }
  }
  </code></pre>
  
  <p>Exists some solution for this problem? I want avoid hard coded key type for base repository. What just come to my mind is write method Find as virtual (or abstract) and then create special repository for long-key entities, string-key entities, but... It's not solution but just workaround...</p>