Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
AutoMapper throws an error - how to figure out?
Message
From
13/05/2016 04:06:53
 
General information
Forum:
ASP.NET
Category:
Third party products
Environment versions
Environment:
C# 5.0
OS:
Windows 10
Database:
MS SQL Server
Miscellaneous
Thread ID:
01636216
Message ID:
01636322
Views:
48
>How can I make AutoMapper ignore our BaseClass ViewModel properties?
>
>I added the following
>
>
>public class AutoMapperConfig
>    {
>        public static MapperConfiguration mapperConfiguration = new MapperConfiguration(cfg =>
>        {
>            cfg.AddProfile(new MappingProfile());
>            cfg.ShouldMapProperty = pi => !pi.Name.InList( "HiddenSwitch","ErrorMessage","SuccessMessage", "WarningMessage","DuplicateForm"); // this is the line I added
>        });
>        public static IMapper Mapper;
>
>        public static void Configure()
>        {
>            Mapper = mapperConfiguration.CreateMapper();
>            mapperConfiguration.AssertConfigurationIsValid(); // This line I added
>        }
>    }
>
>But I still got these properties listed as unmapped.

Seems to me you are saying 'should map properties except 'HiddenSwitch' etc. That's not the same as saying ' don't map 'HiddenSwitch' etc. But I'm not clear on what you are trying to achieve (or why). Can you post a simple set of source and destination classes (with parent classes) that demonstrate.

Automapper group is here : https://groups.google.com/forum/#!forum/automapper-users
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform