public class Order
{
public int OrderId { get; set; }
public string OrderCode { get; set; }
public IList<OrderItem> OrderItems { get; set; }
}
public class OrderDTO
{
public string OrderId { get; set; }
public string IdentifiableCode { get; set; }
public decimal TotalCost { get; set; }
public ICollection OrderItems { get; set; }
}
public class OrderItem
{
public int OrderItemId { get; set; }
public int ItemCount { get; set; }
public Order Order { get; set; }
}
public class OrderItemDTO
{
public int OrderItemId { get; set; }
public int ItemCount { get; set; }
public OrderDTO Order { get; set; }
}
在這種情況下,如何將ILIist的OrderItems映射到ICollection。我嘗試使用解析器,但以遞歸結束,因爲OrderItem具有Order引用。通過AutoMapper將IList映射到ICollection
任何想法?
你爲什麼需要實施aftermap與foreach循環。它不是自動映射的嗎?你能爲我這樣的初學者更好地啓發這個嗎? – batmaci 2016-11-30 12:53:49