Available on nuget
PM> Install-Package TinyMapper
TinyMapper.Bind<Person, PersonDto>();
var person = new Person
{
Id = Guid.NewGuid(),
FirstName = "John",
LastName = "Doe"
};
var personDto = TinyMapper.Map<PersonDto>(person);
Ignore mapping source members and bind members with different names/types
TinyMapper.Bind<Person, PersonDto>(config =>
{
config.Ignore(x => x.Id);
config.Ignore(x => x.Email);
config.Bind(source => source.LastName, target => target.Surname);
config.Bind(target => source.Emails, typeof(List<string>));
});
var person = new Person
{
Id = Guid.NewGuid(),
FirstName = "John",
LastName = "Doe",
Emails = new List<string>{"[email protected]", "[email protected]"}
};
var personDto = TinyMapper.Map<PersonDto>(person);
TinyMapper
supports the following platforms:
- .Net 3.5+
- .NET Standard 1.3
- .NET Core
- Mono
- TinyMapper: yet another object to object mapper for .net
- Complex mapping
- How to create custom mapping
A big thanks to all of TinyMapper's contributors: