AutoMapper/AutoMapper — Issue #162: ForMember overload with string does not support members, it only supports properties
Author: danielcrenna
Created: 2011-12-21 18:49:42+00:00
State: open

The ForMember method can take an expression, in which case it uses ReflectionHelper to resolve to IMemberAccessor (which works for fields or properties). But the overload that takes a string only looks for Properties, not members (i.e. fields). Which means when you try anything custom on fields it throws a NullReferenceException. For performance reasons due to another dependency, we have to use public fields, not public properties.