feat(IRepositoryFactory): create to capsulate repository geenration.
- update DbRepo to use IRepositoryFactory
This commit is contained in:
parent
7d3d3b5ae9
commit
272650d991
@ -0,0 +1,6 @@
|
||||
namespace DigitalData.Core.Abstraction.Application.Repository;
|
||||
|
||||
public interface IRepositoryFactory
|
||||
{
|
||||
public IRepository<TEntity> Get<TEntity>();
|
||||
}
|
||||
@ -79,12 +79,12 @@ public class DbRepository<TDbContext, TEntity> : IRepository<TEntity> where TDbC
|
||||
|
||||
public class DbRepository : IRepository
|
||||
{
|
||||
private readonly IServiceProvider _provider;
|
||||
private readonly IRepositoryFactory _factory;
|
||||
|
||||
public DbRepository(IServiceProvider provider)
|
||||
public DbRepository(IRepositoryFactory factory)
|
||||
{
|
||||
_provider = provider;
|
||||
_factory = factory;
|
||||
}
|
||||
|
||||
public IRepository<TEntity> Entity<TEntity>() => _provider.GetRequiredService<IRepository<TEntity>>();
|
||||
public IRepository<TEntity> Entity<TEntity>() => _factory.Get<TEntity>();
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user