Skip to content
Sergey Morenko edited this page Apr 12, 2015 · 2 revisions

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 = "support@tinymapper.net",
};

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

var personDto = TinyMapper.Map<PersonDto>(person);

Clone this wiki locally