2

オートマッパーを 3.2 から 4.2 にアップグレードしようとしていますが、GetAllTypeMaps がどこに移動したか、または次の方法を理解するのに助けが必要です。私はすべてのマップを取得し、タイプが「Command」で「DateCreated」を無視するマップを見つけていました。コードは次のとおりです。

 private void IgnoreDateCreateForAllCommands()
        {
            foreach (var map in Mapper.GetAllTypeMaps())
            {
                if (typeof(Command).IsAssignableFrom(map.DestinationType))
                {
                    var propInfo = map.DestinationType.GetProperty("DateCreated");
                    if (propInfo != null)
                    {
                        map.FindOrCreatePropertyMapFor(new AutoMapper.Impl.PropertyAccessor(propInfo)).Ignore();
                    }
                }
            }
        }

おそらく 4.2 でこれを行うためのより簡単な方法があると思いますか?

4

0 に答える 0