using System.Collections.Generic;
using AgileObjects.AgileMapper;
public static void Main()
.From<Address>().To<AddressDto>()
.MapInstancesUsing(ctx => new AddressDto
Number = ctx.Source.HouseNo,
Line1 = ctx.Source.Street,
Line4 = ctx.Source.County,
Postcode = ctx.Source.PostalCode
var source = new AddressBook
Addresses = new List<Address>
Street = "Mapper Street",
County = "Mapper County",
var result = Mapper.Map(source).ToANew<AddressBookDto>();
foreach (var dto in result.Addresses)
Console.WriteLine(string.Join(
new[] { dto.Number.ToString(), dto.Line1, dto.Line2, dto.Line3, dto.Line4, dto.Postcode }.Where(a => a != null)));
Console.WriteLine(Mapper.GetPlanFor<AddressBook>().ToANew<AddressBookDto>());
public List<Address> Addresses { get; set; }
public int HouseNo { get; set; }
public string Street { get; set; }
public string Town { get; set; }
public string City { get; set; }
public string County { get; set; }
public string PostalCode { get; set; }
public List<AddressDto> Addresses { get; set; }
public int Number { get; set; }
public string Line1 { get; set; }
public string Line2 { get; set; }
public string Line3 { get; set; }
public string Line4 { get; set; }
public string Postcode { get; set; }