我正在使用 EF Core,并且两个表之间存在多对多关系。
public class Sale
{
public int Id { get; set; }
public DateTime Date { get; set; }
public double Total { get; set; }
public List<SalePaymentMethod> SalePaymentMethods { get; set; }
}
加入表:
public class SalePaymentMethod
{
public int DefferedPaymentCount { get; set; }
public int SaleId { get; set; }
public Sale Sale { get; set; }
public double Amount { get; set; }
public int PaymentMethodId { get; set; }
public PaymentMethod PaymentMethod { get; set; }
}
关系的另一个表:
public class PaymentMethod
{
public int Id { get; set; }
public string PaymentName { get; set; }
public bool PaymentType { get; set; }
public List<SalePaymentMethod> SalePaymentMethods { get; set; }
}
我可以使用 AutoMapper 获得如下所示的扁平对象吗?
public class SaleUserBranchProductsDTO
{
public int Id { get; set; }
public DateTime Date { get; set; }
public double Total { get; set; }
public List<PaymentMethodDto> PaymentMethods { get; set; }
}
PaymentMethodDto 是:
public class PaymentMethodDto
{
public string PaymentName { get; set; }
public bool PaymentType { get; set; }
public int DefferedPaymentCount { get; set; }
public double Amount { get; set; }
}
我的问题可能是我想在主映射中进行另一个映射。