Skip to content

DynamicField/NotSoAutoMapper

Repository files navigation

NotSoAutoMapper

A library to map your DTOs with reusable expressions.

Build Status

  • NuGet packages :

    • NotSoAutoMapper
      Nuget
    • NotSoAutoMapper.Extensions.Ioc.DependencyInjection: support for MS DI
      Nuget
    • NotSoAutoMapper.Extensions.Ioc.DryIoc: support for DryIoc
      Nuget
  • Documentation

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