这是我的域模型的表示:
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; }
}
这是我的实体类:
public class AddressEntity
{
public int Id { get; set; }
public string Name { get; set; }
public AddressInfo AddressInfo { get; set; }
}
这是我的存储库的表示,我可以在其中检索值但不能以我想要的方式映射它们。
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);
}
}
如何创建地图以便处理 AddressInfo ????
目前它没有填充检索到的值,因为它显然没有映射。