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