Hi, I don't know if I'm missing something but this behaviour seems strange to me.
I take one of slapper examples:
public class Customer
{
public int CustomerId;
public string FirstName;
public string LastName;
public IList<Order> Orders;
}
public class Order
{
public int OrderId;
public decimal OrderTotal;
public IList<OrderDetail> OrderDetails;
}
public class OrderDetail
{
public int OrderDetailId;
public decimal OrderDetailTotal;
}
I change the data of the example to not have an OrderDetail
var dictionary = new Dictionary<string, object>
{
{ "CustomerId", 1 },
{ "FirstName", "Bob" },
{ "LastName", "Smith" },
{ "Orders_OrderId", 1 },
{ "Orders_OrderTotal", 50.50m },
{ "Orders_OrderDetails_OrderDetailId", DBNull.Value },
{ "Orders_OrderDetails_OrderDetailTotal", DBNull.Value }
};
var list = new List<IDictionary<string, object>> { dictionary };
// Act
var customers = Slapper.AutoMapper.Map<Customer>(list);
Now I expect to have a Customer with 1 Order and either an empty list of OrderDetails or a null OrderDetails object but instead I get an OrderDetails list with one OrderDetails instance with both OrderDetailId and OrderDetailTotal equal to 0.
Am I missing something? Is there a way that I can use to achieve the result?
In my project I have some complex object with nested list where I have this problem, could you please help me?
Hi, I don't know if I'm missing something but this behaviour seems strange to me. I take one of slapper examples:
I change the data of the example to not have an OrderDetail
Now I expect to have a Customer with 1 Order and either an empty list of OrderDetails or a null OrderDetails object but instead I get an OrderDetails list with one OrderDetails instance with both OrderDetailId and OrderDetailTotal equal to 0. Am I missing something? Is there a way that I can use to achieve the result? In my project I have some complex object with nested list where I have this problem, could you please help me?
Manny thanks, Alessandro