How to solve this generic with repository pattern problem?

c#, design-patterns, generics, repository-pattern

Solution

You need to use two type arguments when inheriting from Repository/IRepository because they take take two type arguments. Namely, when you inherit from IRepository, you need to specify something like:

public class Repository<T, TID> : IRepository<T,TID> where T:IEntity

and

public class CustomerRepository : Repository<ICustomer,int>,ICustomerRepository

Edited to add type constraint on implementation of Reposistory

Problem

I had this code from a previous question, but its not compiling: ``` public interface IEntity { // Common to all Data Objects } public interface ICustomer : IEntity { // Specific data for a customer } public interface IRepository<T, TID> : IDisposable where T : IEntity { T Get(TID key); IList<T> GetAll(); void Save (T entity); T Update (T entity); // Common data will be added here } public class Repository<T, TID> : IRepository { // Implementation of the generic repository } public interface ICustomerRepository { // Specific operations for the customers repository } public class CustomerRepository : Repository<ICustomer>, ICustomerRepository { // Implementation of the specific customers repository } ``` But in these 2 lines : 1- public class Repository : IRepository 2- public class CustomerRepository : Repository, ICustomerRepository It give me this error: Using the generic type 'TestApplication1.IRepository' requires '2' type arguments can you help me solve?

Original source