I have two classes:
public class Customer
{
public string FirstName { get; set; }
public string LastName { get; set; }
};
public class Customer_
{
public string FirstNam { get; set; }
public string LastNam { get; set; }
}
And one instance of my class Customer:
Customer[] Customer = new Customer[]
{
new Customer()
{
FirstName = "FirstName1",
LastName = "LastName1"
},
new Customer()
{
FirstName = "FirstName2",
LastName = "LastName2"
}
};
I want to map my object Customer to an instance of my object Customer_.
I use Automapper:
var config = new MapperConfiguration(cfg =>
{
cfg.CreateMap<Customer, Customer_>();
});
IMapper mapper = config.CreateMapper();
var dest = mapper.Map<Customer[], Customer_[]>(Customer);
But the object dest is have two index null
How to create the map and and define mappings ? For example : Customer.FirstName = Customer_.FirstName ...etc
Edit :
I add a new property Quantity (type int) in my class Customer and a value in my instance. Now, I want to map only customer who have a quantity > x
Customer[] Customer = new Customer[]
{
new Customer()
{
FirstName = "FirstName1",
LastName = "LastName1",
Quantity = 11
},
new Customer()
{
FirstName = "FirstName2",
LastName = "LastName2",
Quantity = 5
}
};
How do to ?