{"action":"created","issue":{"url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/751","labels_url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/751/labels{/name}","comments_url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/751/comments","events_url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/751/events","html_url":"https://github.com/AutoMapper/AutoMapper/issues/751","id":90854696,"number":751,"title":"Unexpectedly called mapping.","user":{"login":"solo12zw74","id":589910,"avatar_url":"https://avatars.githubusercontent.com/u/589910?v=3","gravatar_id":"","url":"https://api.github.com/users/solo12zw74","html_url":"https://github.com/solo12zw74","followers_url":"https://api.github.com/users/solo12zw74/followers","following_url":"https://api.github.com/users/solo12zw74/following{/other_user}","gists_url":"https://api.github.com/users/solo12zw74/gists{/gist_id}","starred_url":"https://api.github.com/users/solo12zw74/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/solo12zw74/subscriptions","organizations_url":"https://api.github.com/users/solo12zw74/orgs","repos_url":"https://api.github.com/users/solo12zw74/repos","events_url":"https://api.github.com/users/solo12zw74/events{/privacy}","received_events_url":"https://api.github.com/users/solo12zw74/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-06-25T04:58:21Z","updated_at":"2015-06-26T04:22:35Z","closed_at":null,"body":"Hi there! The question is \"Why mapping calls unexpectedly when i dont call it?\". I hope my sample code illustrate it better than any words\r\n\r\n```c#\r\nclass Program\r\n    {\r\n        static void Main(string[] args)\r\n        {\r\n            Mapper.CreateMap<DtoChild, DoChild>()\r\n                .ForMember(doChild => doChild.CommonClassProperty, dtoChild => dtoChild.ResolveUsing<DtoChildToDoChildResolver>());\r\n\r\n            Mapper.CreateMap<DtoClass, DoClass>()\r\n                .ForMember(@do => @do.DoChildren, dto => dto.ResolveUsing<DtoToDoChildResolver>());\r\n\r\n            Mapper.CreateMap<DoChild, DoChild>()\r\n                .BeforeMap((s, d) => Console.WriteLine(\"2. Then <DoChild, DoChild> mapping called unexpectedly\"))\r\n                .ForMember(@do => @do.CommonClassProperty, dto => dto.Ignore());\r\n\r\n            var source = new DtoClass\r\n            {\r\n                Id = 0,\r\n                DtoChildren = new List<DtoChild> { new DtoChild { CommonClassPropertyName = \"DtoChild1\" } }\r\n            };\r\n\r\n            var dest = Mapper.Map<DtoClass, DoClass>(source);\r\n\r\n            dest.DoChildren.ForEach(c => Console.WriteLine(\"3. And after unexpected call of <DoChild, DoChild> mapping CommonClass property is {0}\", c.CommonClassProperty ?? (object)\"null\"));\r\n            Console.WriteLine(\"4. The question is \\\"Why <DoChild, DoChild> calls?\\\"\");\r\n\r\n            Console.ReadKey();\r\n        }\r\n\r\n\r\n        public class DtoClass\r\n        {\r\n            public int Id { get; set; }\r\n            public List<DtoChild> DtoChildren { get; set; }\r\n        }\r\n\r\n        public class DtoChild\r\n        {\r\n            public string CommonStringName { get; set; }\r\n            public string CommonClassPropertyName { get; set; }\r\n\r\n        }\r\n\r\n        public class DtoToDoChildResolver : ValueResolver<DtoClass, List<DoChild>>\r\n        {\r\n            protected override List<DoChild> ResolveCore(DtoClass source)\r\n            {\r\n                var result = Mapper.Map<List<DtoChild>, List<DoChild>>(source.DtoChildren);\r\n                foreach (var child in result)\r\n                {\r\n                    Console.WriteLine(\"1. After calling \\\"DtoToDoChildResolver\\\" CommonClassPropertyName is \\\"{0}\\\" (as expected)\", child.CommonClassProperty.CommonClassPropertyName);\r\n                }\r\n                return result;\r\n            }\r\n        }\r\n\r\n        public class DtoChildToDoChildResolver : ValueResolver<DtoChild, CommonClass>\r\n        {\r\n            protected override CommonClass ResolveCore(DtoChild source)\r\n            {\r\n                return new CommonClass { CommonClassPropertyName = source.CommonClassPropertyName };\r\n            }\r\n        }\r\n\r\n        public class CommonClass\r\n        {\r\n            public string CommonClassPropertyName { get; set; }\r\n        }\r\n\r\n        public class DoClass\r\n        {\r\n            public int Id { get; set; }\r\n            public List<DoChild> DoChildren { get; set; }\r\n        }\r\n\r\n        public class DoChild\r\n        {\r\n            public string CommonStingName { get; set; }\r\n            public CommonClass CommonClassProperty { get; set; }\r\n        }\r\n\r\n    }\r\n```\r\n\r\nOutput:\r\n> 1. After calling \"DtoToDoChildResolver\" CommonClassPropertyName is \"DtoChild1\" (as expected)\r\n> 2. Then `<DoChild, DoChild>` mapping called unexpectedly\r\n> 3. And after unexpected call of `<DoChild, DoChild>` mapping CommonClass property is null\r\n> 4. The question is \"Why `<DoChild, DoChild>` calls?\"\r\n\r\nWhat am i doing wrongWhat do i wrong?"},"comment":{"url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/comments/115495961","html_url":"https://github.com/AutoMapper/AutoMapper/issues/751#issuecomment-115495961","issue_url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/751","id":115495961,"user":{"login":"solo12zw74","id":589910,"avatar_url":"https://avatars.githubusercontent.com/u/589910?v=3","gravatar_id":"","url":"https://api.github.com/users/solo12zw74","html_url":"https://github.com/solo12zw74","followers_url":"https://api.github.com/users/solo12zw74/followers","following_url":"https://api.github.com/users/solo12zw74/following{/other_user}","gists_url":"https://api.github.com/users/solo12zw74/gists{/gist_id}","starred_url":"https://api.github.com/users/solo12zw74/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/solo12zw74/subscriptions","organizations_url":"https://api.github.com/users/solo12zw74/orgs","repos_url":"https://api.github.com/users/solo12zw74/repos","events_url":"https://api.github.com/users/solo12zw74/events{/privacy}","received_events_url":"https://api.github.com/users/solo12zw74/received_events","type":"User","site_admin":false},"created_at":"2015-06-26T04:22:35Z","updated_at":"2015-06-26T04:22:35Z","body":"> @lbargaoanu \r\n> It does look like a bug. It works with without Mapper.CreateMap< DoChild, DoChild >(). Do you really need that?\r\n\r\nWe find it too, but we really need this mapping in other parts of our app.\r\n\r\nSo i hope @jbogard find a time to look on it."}}