refactor(repository): replace queryFactory with DbSetFactory in DbRepository
- Updated DbRepository constructor to use DbSetFactory<TDbContext, TEntity> instead of a Func<TDbContext, DbSet<TEntity>> queryFactory. - Adjusted namespace imports to include DigitalData.Core.Infrastructure.Factory. - Improved repository instantiation consistency and encapsulation.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using AutoMapper;
|
||||
using DigitalData.Core.Abstraction.Application.Repository;
|
||||
using DigitalData.Core.Infrastructure.Factory;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
@@ -13,10 +14,10 @@ public class DbRepository<TDbContext, TEntity> : IRepository<TEntity> where TDbC
|
||||
|
||||
public IMapper Mapper { get; }
|
||||
|
||||
public DbRepository(TDbContext context, Func<TDbContext, DbSet<TEntity>> queryFactory, IMapper mapper)
|
||||
public DbRepository(TDbContext context, DbSetFactory<TDbContext, TEntity> factory, IMapper mapper)
|
||||
{
|
||||
Context = context;
|
||||
Entities = queryFactory(context);
|
||||
Entities = factory.Create(context);
|
||||
Mapper = mapper;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user