Repeat: Can you post a simple set of source and destination classes (with parent classes). Showing your mapping code without the relevant classes doesn't help much.
BTW, why are you using the .AddGlobalIgnore()'s and the ' IgnoreAllNonExisting()' extension ?
And what is IgnoreAllNonExistingSource() for ?
>>>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>
>All our ViewModels are based on the BaseViewModel class that has certain properties. These properties are not mapped to our models. I found yesterday (from a few StackOverflow threads) the following way:
>
>
>namespace SysManager.Web
>{
> public class AutoMapperConfig
> {
> public static MapperConfiguration mapperConfiguration = new MapperConfiguration(cfg =>
> {
> cfg.AddGlobalIgnore("HiddenSwitch");
> cfg.AddGlobalIgnore("ErrorMessage");
> cfg.AddGlobalIgnore("SuccessMessage");
> cfg.AddGlobalIgnore("WarningMessage");
> cfg.AddGlobalIgnore("DuplicateForm");
> cfg.AddGlobalIgnore("LastMod");
>
> cfg.AddProfile(new MappingProfile());
>
> });
> public static IMapper Mapper;
>
> public static void Configure()
> {
> Mapper = mapperConfiguration.CreateMapper();
> mapperConfiguration.AssertConfigurationIsValid();
> }
> }
>
> public static class AutoMapperExtensions
> {
> // from http://stackoverflow.com/questions/954480/automapper-ignore-the-rest/6474397#6474397
> public static IMappingExpression IgnoreAllNonExisting(this IMappingExpression expression)
> {
> foreach (var property in expression.TypeMap.GetUnmappedPropertyNames())
> {
> expression.ForMember(property, opt => opt.Ignore());
> }
> return expression;
> }
>
> public static IMappingExpression IgnoreAllNonExistingSource(this IMappingExpression expression)
> {
> foreach (var property in expression.TypeMap.GetUnmappedPropertyNames())
> {
> expression.ForSourceMember(property, opt => opt.Ignore());
> }
> return expression;
> }
>
> public static IMappingExpression<TSource, TDestination> IgnoreAllNonExisting<TSource, TDestination>(this IMappingExpression<TSource, TDestination> expression)
> {
> foreach (var property in expression.TypeMap.GetUnmappedPropertyNames())
> {
> expression.ForMember(property, opt => opt.Ignore());
> }
> return expression;
> }
> }
>
>
>The last 3 extensions I found in StackOverflow. The problem is now that I have to add the call to IgnoreAllNonExisting() to every map and we have more than a hundred in the AutoMapperConfig file.
>
>Anyway, I am afraid my problem is not going to be resolved as the AssertConfigurationIsValid() is not even complaining about that particular model, but it still errors out when I try to instantiate it.
>
>Here is the class GstPass (auto-generated by Reverse POCO Generator):
>
>
> public string @Operator { get; set; } // operator (length: 6)
> InitializePartial();
> }
>
> partial void InitializePartial();
> }
>
>}
>// </auto-generated>
>
>
>and this is view model for that class which used to work before (may be 2 months ago I tested it last time):
>
>
>I commented out the iValueInject and I also played before with commenting all complex properties and it still produced the same error when I tried to use
>
>
> EditPassViewModel guestPassViewModel = Mapper.Map<GstPass, EditPassViewModel>(guestPass);
>
>Last night I was busy adding that IgnoreAllNonExisting() calls to all our maps and at about 11:30pm I decided to stop. I haven't re-tested today yet, but I doubt it will help with this problem.
>
>May be you can spot something right away.
>
>Thanks in advance.
>
>UPDATE. It helps to post the whole code. I think I spotted the problem now:
>
>The GstPass has the following property
>
>
>public string @Operator { get; set; } // operator (length: 6)
>
>This may be a problem. It's new Reverse POCO generator making that property with @. I thought I found a solution before, but may be not.
>
>I bet this is what is making this thing not work.