This is a representation of my domain model:
public class AddressInfo
{
private readonly string addressee;
private readonly string company;
private readonly string city;
public string Addressee
{
get { return addressee; }
}
public string Company
{
get { return company; }
}
public string City
{
get { return city; }
}
}
public class Address
{
public int Id { get; set; }
public string Name { get; set; }
public AddressInfo AddressInfo { get; set; }
}
This is my entity class:
public class AddressEntity
{
public int Id { get; set; }
public string Name { get; set; }
public AddressInfo AddressInfo { get; set; }
}
This is the representation of my repository where I am able to retrieve the values but not map them in the way I want to.
public class AddressRepository
{
public static void CreateMappings()
{
//How to construct a map here to take care of
//the map creation of AddressInfo??
Mapper.CreateMap<AddressEntity, Address>();
}
public IEnumerable<Address> GetAllAddresses (User user)
{
var addressentities = GetAddresses(user.Id);
return addressentities == null?
null:
Mapper.Map<IEnumerable<Address>>(addressentities);
}
}
How to create the map so that AddressInfo is taken care of ????
Currently it is not populated with the retrieved values as it is obviously not mapped.