Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issue #656. Mapping init Property #658

Draft
wants to merge 4 commits into
base: development
Choose a base branch
from

Conversation

DocSvartz
Copy link

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

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) {};
}



Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant