以下のようなソースオブジェクトがあります。
Class Employee
{
int EmpID { get; set; }
string EmpName { get; set; }
List<AddressRelation> AddressRelations { get; set; }
}
Class AddressRelation
{
int AddressRelationId { get; set; }
int AddressTypeId { get; set; }
int AddressId { get; set; }
}
Class Address
{
int AddressId { get; set; }
string AddressLine1 { get; set; }
string AddressLine2 { get; set; }
string City { get; set; }
string State { get; set; }
string Zip { get; set; }
}
**Destination Object**
Class EmployeeDTO
{
int EmpID { get; set; }
string EmpName { get; set; }
List<AddressDTO> Addresses { get; set; }
}
Class AddressDTO
{
int AddressId { get; set; }
string AddressLine1 { get; set; }
string AddressLine2 { get; set; }
string City { get; set; }
string State { get; set; }
string Zip { get; set; }
}
現在、ソース オブジェクトには AddressRelation コレクションがあり、その Address のリスト内に存在します。つまり、従業員には 0-n の AddressRelation があり、各 AddressRelation 内には 0-n の Address があります。
ここで、Automapper を使用してソース オブジェクトのアドレスのみをマップし、それを宛先オブジェクトのアドレス コレクションに割り当てたいと考えています。各 AddressRelation を反復し、Addresses を取得して Destination オブジェクトの Address Collection に割り当てることを意味します。AutoMapper を使用してこれを行う方法は?
前もってありがとう、プラカシュ。