Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
AutoMapper throws an error - how to figure out?
Message
 
 
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:
01636301
Views:
41
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.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform