When I asked this question about AutoMapper and protected
properties, I received a response from Jimmy Bogard (AutoMapper co-creator). He suggested that we can initialize the BindingFlags
using the code that I pasted below. The problem is, I get the following error and don't know how to fix it:
"AutoMapper.IConfiguration does not contain a definition for 'BindingFlags' and no extension method..."
Here's the code:
Mapper.Initialize(cfg =>
{
cfg.BindingFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance;
cfg.CreateMap<PolicyDetail, Policy>();
});
UPDATE:
I didn't have AutoMapper 3.3.0. Once I updated, this code worked. Thanks to Gert Arnold.