NotSoAutoMapper
A library to map your DTOs with reusable expressions.
-
NuGet packages :
Showcase
var catDtoMapper = new Mapper<Cat,CatDto>(x => new CatDto
{
Id = x.Id,
Name = x.Name,
CutenessLevel = x.CutenessLevel
});
var personDtoMapper = new Mapper<Person, PersonDto>(x => new PersonDto
{
Id = x.Id,
FirstName = x.FirstName,
LastName = x.LastName,
Cat = x.Cat.MapWith(catDtoMapper) // Use the catDtoMapper
});
PersonDto personDto = personDtoMapper.Map(somePerson); // personDto.Cat is a CatDto!
Console.WriteLine($"{personDto.FirstName} has a cute cat named {personDto.Cat.Name}");
// >>> James has a cute cat named Felix