1

With the following mapping I am able to selectively choose which property values to map based on their values.

config
  .CreateMap<SourceAddress, DestinationAddress>()
  .ForAllMembers(opt => opt.Condition((s, d, sv, dv, rc) => true));

How would I go about making this decision based on the property metadata, like its name or attributes applied to it?

Note that when I break in the implementation of the condition delegate, the ResolutionContext parameter rc has both InstanceCache and Items empty.

2
  • 1
    Maybe you should give an example of what you're trying to achieve. This is kind of vague. Commented Jul 17, 2016 at 21:22
  • Sorry, I thought I was clear. I was asking what @Timothy Ghanem answered. Commented Jul 17, 2016 at 21:30

1 Answer 1

2

AutoMapper does allow Global property/field filtering. So you can try using this in your MapperConfiguration:

var config = new MapperConfiguration(cfg =>
{
    cfg.ShouldMapProperty = pi =>
    {
        return true;
    };
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.