How to resolve generic interface to generic implementation when using dependency injection?
问题 I have created a generic repository that I want to be used in a service. public abstract class AbstractBaseRepository<TEntity, TEntityKey> : IBaseRepository<TEntity, TEntityKey> where TEntity : class, IBaseEntity<TEntityKey>, new() { /* some code */ } And the interface: public interface IBaseRepository<TEntity, TEntityKey> { /* some code */ } On my service I inject the repository like this: public class TenantsService : AbstractBaseService<TenantEntity, int> { public TenantsService