Added AutoMapper support by introducing an IMapper field. Changed Context and Entities fields to readonly for better encapsulation. Updated constructor to accept an IMapper parameter, improving object mapping capabilities.
48 lines
1.4 KiB
C#
48 lines
1.4 KiB
C#
using AutoMapper;
|
|
using DigitalData.Core.Abstractions.Infrastructure;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using System.Linq.Expressions;
|
|
|
|
namespace DigitalData.Core.Infrastructure;
|
|
|
|
public class DbRepository<TDbContext, TEntity> : IRepository<TEntity> where TDbContext : DbContext where TEntity : class
|
|
{
|
|
protected readonly TDbContext Context;
|
|
|
|
protected readonly DbSet<TEntity> Entities;
|
|
|
|
protected readonly IMapper Mapper;
|
|
|
|
public DbRepository(TDbContext context, Func<TDbContext, DbSet<TEntity>> queryFactory, IMapper mapper)
|
|
{
|
|
Context = context;
|
|
Entities = queryFactory(context);
|
|
Mapper = mapper;
|
|
}
|
|
|
|
public Task<TEntity> CreateAsync(TEntity dto, CancellationToken ct = default)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public Task<TEntity> CreateAsync(IEnumerable<TEntity> dtos, CancellationToken ct = default)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public Task<IEnumerable<TEntity>> DeleteAsync<TDto>(Expression expression, CancellationToken ct = default)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public Task<IEnumerable<TEntity>> ReadAsync(Expression? expression = null, CancellationToken ct = default)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public Task<IEnumerable<TEntity>> UpdateAsync<TDto>(TDto dto, Expression expression, CancellationToken ct = default)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|