Property not Getting Mapped
Hey, there.
I encountered an strange mapping bug, i am literally mapping from the same type to itself but an specific nested property gets null (Order.Payment.CVV)
here is the code:
public record CreateOrderRequest(OrderDTO Order);
public record CreateOrderCommand(OrderDTO Order) ;
public record OrderDTO
(
Guid Id,
Guid CustomerId,
string OrderName,
AddressDTO ShippingAddress,
AddressDTO BillingAddress,
PaymentDTO Payment,
OrderStatus Status,
List<OrderItemDTO> OrderItems
);
public record PaymentDTO
(
string CardName,
string CardNumber,
string Expiration,
string CVV,
int PaymentMethod
);
public void test(CreateOrderRequest request)
{
var tmp = request.Adapt<CreateOrderCommand>();
}
Mapster Version: 7.4.0
.Net Version: 8
PS. I have debugged the code and the CVV field does have a value before mapping
@IPdotSetAF yes, i hope it wil be fix in the next release. this setting should help you
TypeAdapterConfig<PaymentDTO, PaymentDTO>
.NewConfig()
.NameMatchingStrategy(NameMatchingStrategy.IgnoreCase)
Thanks @DocSvartz for the fast reply and recommendation. I would also like to start contributing in the project. if there was any chance feel free to mention me.
linked #746
@andrerav @stagep This is because the Constructor Parameter Names are forced to PascalCase. Then Name Matching Strategy is no longer able Match Parametr and Property from source , since the name does not match.
I found a solution, it will be based on #769 Since it requires an explicit definition that mapping of constructor parameters is performed.
But perhaps there is a simpler solution)