title: How would I implement a solution for unique keys?
body: <p>I have 3 tables:  </p>
  
  <pre><code>Player =&gt; PlayerId (Primary Key), Name, etc  
  Team =&gt; TeamId (Primary Key), Name, etc  
  PlayerTeam =&gt; PlayerId, TeamId (The combination must be unique)  
  </code></pre>
  
  <p>then I have the following:  </p>
  
  <pre><code>public interface IEntityKey&lt;TKey&gt;
  {
      TKey Id { get; }    
  }
  
  public interface IRepository&lt;TKey, TEntity&gt; where TEntity : class, IEntityKey&lt;TKey&gt;
  {
    IQueryable&lt;TEntity&gt; All();
    TEntity FindBy(Expression&lt;Func&lt;TEntity, bool&gt;&gt; expression);
    ....
    TEntity FindBy(TKey id);
  }
  </code></pre>
  
  <p>Now while the above would work fine for tables with a <strong>single</strong> key such as the player or team table, how would I implement it for my playerteam table? What I need is a solution that would cater for <strong>any number of keys</strong>. I would prefer a solution such as ...</p>
  
  <pre><code>public interface IEntityKey&lt;TKey&gt; where TKey : System.Tuple
  {
      TKey Id { get; }    
  }
  </code></pre>
  
  <p>over   </p>
  
  <pre><code>public interface IEntityKey&lt;TKey1, TKey2&gt;
  {
      TKey1 Id1 { get; }    
      TKey2 Id2 { get; }    
  }
  </code></pre>