tags:

views:

47

answers:

1

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 the right direction?

Thanks

+3  A: 

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>
SLaks