21 lines
574 B
C#

using AutoMapper;
using DigitalData.Core.Abstractions.Infrastructure;
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 TEntity Map<TDto>(TDto dto) => _rootMapper.Map<TEntity>(dto);
public TEntity Map<TDto>(TDto dto, TEntity entity) => _rootMapper.Map(dto, entity);
}