Simple mapping - TinyMapper/TinyMapper GitHub Wiki

The sample shows how to map Person to PersonDto

public sealed class Person
{
	public string Email { get; set; }
	public string FirstName { get; set; }
	public Guid Id { get; set; }
	public string LastName { get; set; }
}

and

public sealed class PersonDto
{
	public string Email { get; set; }
	public string FirstName { get; set; }
	public Guid Id { get; set; }
	public string LastName { get; set; }
}

First of all Bind Person type to PersonDto type and we don't want map Email property. So it has been ignored.

TinyMapper.Bind<Person, PersonDto>(config =>
{
	config.Ignore(x => x.Email);
});
var person = new Person
{
	Id = Guid.NewGuid(),
	FirstName = "John",
	LastName = "Doe",
	Email = "[email protected]",
};

Now TinyMapper knows how to map Person object to PersonDto object. Finally, call

var personDto = TinyMapper.Map<PersonDto>(person);
⚠️ **GitHub.com Fallback** ⚠️