Partial fix issue #422
Fix MapToTarget generation to not Public setters (init Prorperty also working in Mapster 7.4.0)
Not Fix AdaptTo - need use .MapToConstructor(true);
example
public class SalesOrder
{
public SalesOrder(){}
public SalesOrder(Guid id, decimal total, string status)
{
Id = id;
Total = total;
Status = status;
}
public Guid Id { get; protected set; }
public decimal Total { get; protected set; }
public string Status { get; protected set; }
}
Bad generation :
public static SalesOrder AdaptToSalesOrder(this SalesOrderDto p1)
{
return p1 == null ? null : new SalesOrder()
{
Id = p1.Id,
Total = p1.Total,
Status = p1.Status
};
}
when using .MapToConstructor(true)
Good generation :
public static SalesOrder AdaptToSalesOrder(this SalesOrderDto p1)
{
return p1 == null ? null : new SalesOrder(p1.Id, p1.Total, p1.Status) {};
}
Fix Issue #656
Partial fix issue #422 Fix MapToTarget generation to not Public setters (init Prorperty also working in Mapster 7.4.0) Not Fix AdaptTo - need use
.MapToConstructor(true)
;example
when using
.MapToConstructor(true)