0
rahulbpatel created
Is there a preferred way to make custom generic repository dependency injection work?
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:
IocManager.Register(typeof(IMyRepository<>),
typeof(MyRepository<>),
Abp.Dependency.DependencyLifeStyle.Transient);
IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());