This should work, but I'm not sure if you want the micro to control it like this:
cfg.AllowNullCollections = true;
cfg.CreateMap<GeneralInfo, GeneralInfo>()
.ForMember(x => x.PersonList, opts => opts.PreCondition((src) => src.PersonList != null));
- , ( , AutoMapper , ) , , . , , , ( , ).
.. , ().
, -, , Condition
, , - , .
PreCondition
, , , , , , .
, , , , - " " PreCondition
( ).
:
... ( ForAllMembers
), , ..
cfg.CreateMap<GeneralInfo, GeneralInfo>()
.ForAllMembers(opts =>
{
opts.PreCondition((src, context) =>
{
var property = opts.DestinationMember as System.Reflection.PropertyInfo;
if (property == null) throw new InvalidOperationException();
var value = property.GetValue(src);
return value != null;
});
}
);
... , , .
( ):
5.2.0 # 1918
(by @LucianBargaoanu), , "" ( , ) . Condition
, /.
PreCondition
( , , PreCondition?).
:
( )
Condition, Ignore # 1940
, (), false # 2111
# 2031