I have the following model where I just modified my IEntity interface to take a generic type since I have multiple identity types.
public interface IEntity<T>
{
T Id { get; set; }
}
public class Product : IEntity<int>
{
public int Id { get; set; }
}
Now I have to modify my IRepository and IProductRepository to reflect this change but I am not sure how.
public interface IRepository<TEntity> where TEntity : IEntity
{
void Add(TEntity entity);
void Delete(TEntity entity);
}
public interface IProductRepository : IRepository<Product>
{
}
Anyone care to push me in 开发者_Python百科the right direction?
Thanks
You need to add a second generic parameter:
public interface IRepository<TEntity, TID> where TEntity : IEntity<TID>
{
void Add(TEntity entity);
void Delete(TEntity entity);
}
public interface IProductRepository : IRepository<Product, int>
精彩评论