MapsterMapper / Mapster

A fast, fun and stimulating object to object Mapper
MIT License
4.29k stars 327 forks source link

Ignore properties #560

Closed urza closed 1 year ago

urza commented 1 year ago

Hi, I like the simplicity and minimalist approach of Mapster.

Is it possible to ignore some properties without creating config?

I would imagine something like this:

sourceObject.Adapt(destObject).Ignore("PropertyToIgnore", "AnotherPropertyToIgnore");

andrerav commented 1 year ago

The Adapt() method is always supposed to return the mapped destination object. This proposal would break that API. It should probably look something like this instead:

sourceObject
    .WithIgnore(...)
        .Adapt(destObject);

You can probably write that extension method yourself. It just needs to wrap TypeAdapterConfig.NewConfig().Ignore(...) and return the sourceObject afterwards.

urza commented 1 year ago

@andrerav Thanks, I will try to do that.