25 lines
816 B
C#
25 lines
816 B
C#
using AutoMapper;
|
|
using DigitalData.Core.Abstraction.Application.Repository;
|
|
|
|
namespace DigitalData.Core.Infrastructure.AutoMapper;
|
|
|
|
public class EntityAutoMapper<TEntity> : IEntityMapper<TEntity>
|
|
{
|
|
private readonly IMapper _rootMapper;
|
|
|
|
public EntityAutoMapper(IMapper rootMapper)
|
|
{
|
|
_rootMapper = rootMapper;
|
|
}
|
|
|
|
public TDto Map<TDto>(TEntity entity) => _rootMapper.Map<TDto>(entity);
|
|
|
|
public IEnumerable<TDto> Map<TDto>(IEnumerable<TEntity> entities) => _rootMapper.Map<IEnumerable<TDto>>(entities);
|
|
|
|
public TEntity Map<TDto>(TDto dto) => _rootMapper.Map<TEntity>(dto);
|
|
|
|
public IEnumerable<TEntity> Map<TDto>(IEnumerable<TDto> dtos) => _rootMapper.Map<IEnumerable<TEntity>>(dtos);
|
|
|
|
public TEntity Map<TDto>(TDto dto, TEntity entity) => _rootMapper.Map(dto, entity);
|
|
}
|