我有实体:
public class Person
{
//properties
public virtual State State { get; set; }
}
public class State
{
//properties
public int StateId { get; set; }
public string StateName { get; set; }
public virtual Address Address{ get; set; }
}
public class Address
{
//properties
public int AddressId { get; set; }
public string City{ get; set; }
public int PostalCode { get; set; }
}
我有一个名为PersonDetails的展平DTO
public class PersonDetails
{
//properties
public string City { get; set; }
public string StateName { get; set; }
public int PostalCode { get; set; }
}
当我进行映射时,它可以工作,但它会为Person实体创建一个新的State和Adress。
如何使用AutoMapper从PersonDetails
映射到PersonEntity
?