我有一个像这样的模型类:
public class mOrder
{
public int Id { get; set; }
public List<Models.mOrderPay> OrderPays { get; set; } = new List<mOrderPay>();
}
public class mOrderPay
{
public int Id { get; set; }
public int OrderId { get; set; }
public int Amount { get; set; }
}
和这样的EF表结构:
table | Order
-------------------
PK | int | Id
-------------------
.....
table | OrderPay
-------------------
PK | int | Id
FK | int | OrderId - to Order.Id
| int | Amount
我想通过Automapper将EF类转换为模型类,怎么办?
答案 0 :(得分:0)
cfg.CreateMap<Dal.Order, Models.mOrder>()
.ForMember(s => s.OrderPays, c => c.MapFrom(m => m.OrderPays));