feat(EntityAutoMapper): Erstellt mit der Konfiguration der Dependency Injection.

This commit is contained in:
Developer 02
2025-04-22 15:15:52 +02:00
parent 3c1bbc1151
commit 65e834784a
5 changed files with 90 additions and 1 deletions

View File

@@ -0,0 +1,20 @@
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);
}