This forum is not used anymore. Please ask new questions to Stack Overflow: https://stackoverflow.com/questions/tag ... ort=newest (use aspnetboilerplate tag).
By rahulbpatel
#2281 Is there a preferred way to make custom generic repository dependency injection work?

Code: Select all 
public interface IMyRepository<TEntity> : IRepository<TEntity, Guid>
        where TEntity : class, IEntity<Guid>  {
}

public class MyRepository<TEntity> : MyRepositoryBase<TEntity, Guid>, IMyRepository<TEntity>
        where TEntity : class, IEntity<Guid> {
        public MyRepository(IDbContextProvider<MyDbContext> dbContextProvider)
            : base(dbContextProvider) {
        }
    }


I am currently adding this code in my module initialization to make it work:

Code: Select allIocManager.Register(typeof(IMyRepository<>),
  typeof(MyRepository<>),
  Abp.Dependency.DependencyLifeStyle.Transient);

IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());