I have two tables (lists): customers and sales that have an one-to-many relationship. I'm trying to create an automap that results in a list populated with CustomerSalesDto. For every Sale object a new CustomerSalesDto should be created with the Sale information and some of the information from the Customer who made the sale.
Can this be done with Automapping and how would I accomplish this?
public class Customer
{
public int Id { get; set; }
public string Name { get; set; }
public string Email { get; set; }
}
public class Sale
{
public int Id { get; set; }
public double Price { get; set; }
public DateTime Date { get; set; }
public int CustomarId { get; set;} // Id from Customer who made a sale.
}
public class CustomerSalesDto
{
public double Price { get; set; } // from Sale
public DateTime Date { get; set; } // from Sale
public string Name { get; set; } // from Customer
public string Email { get; set; } // from Customer
}