AutoMapper issue #3962 was closed and locked without explanation or resolution. (In fact, all AutoMapper issues are being treated this way. The maintainer is directing people here.)
To summarize the issue, IMemberConfigurationExpression.Condition
receives a Func<TSrc, TDest, object, bool>
. The third parameter is the value of the source member being visited. For example:
public static class IMappingExpressionExtensions
{
public static void Coalesce<Src, Dst>(this IMappingExpression<Src, Dst> exp)
{
exp.ForAllMembers(cfg => cfg.Condition((src, dst, srcMember) => srcMember != null));
}
}
When the source member is a reference type and its value is null, srcMember
is null as expected. But when the source member is a Nullable<T>
without a value, srcMember
is unexpectedly default(T)
instead of null.
Is there a workaround?