0
我有3個表:我將如何實現唯一密鑰的解決方案?
Player => PlayerId (Primary Key), Name, etc
Team => TeamId (Primary Key), Name, etc
PlayerTeam => PlayerId, TeamId (The combination must be unique)
話,我有以下幾點:
public interface IEntityKey<TKey>
{
TKey Id { get; }
}
public interface IRepository<TKey, TEntity> where TEntity : class, IEntityKey<TKey>
{
IQueryable<TEntity> All();
TEntity FindBy(Expression<Func<TEntity, bool>> expression);
....
TEntity FindBy(TKey id);
}
現在雖然上述會工作的優良表,並單鍵,如球員或球隊表,我將如何爲我的playerteam表實現它?我需要的是一個解決方案,可以滿足任意數量的密鑰。我希望能有一個解決方案,如...
public interface IEntityKey<TKey> where TKey : System.Tuple
{
TKey Id { get; }
}
在
public interface IEntityKey<TKey1, TKey2>
{
TKey1 Id1 { get; }
TKey2 Id2 { get; }
}
哦,我的話......答案很簡單......謝謝托馬斯 – Eminem