{"action":"created","issue":{"url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/1276","repository_url":"https://api.github.com/repos/AutoMapper/AutoMapper","labels_url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/1276/labels{/name}","comments_url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/1276/comments","events_url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/1276/events","html_url":"https://github.com/AutoMapper/AutoMapper/issues/1276","id":154978757,"number":1276,"title":"Incorrect Mapping Inheritance with existing destination object","user":{"login":"christophe12sopra","id":16596714,"avatar_url":"https://avatars.githubusercontent.com/u/16596714?v=3","gravatar_id":"","url":"https://api.github.com/users/christophe12sopra","html_url":"https://github.com/christophe12sopra","followers_url":"https://api.github.com/users/christophe12sopra/followers","following_url":"https://api.github.com/users/christophe12sopra/following{/other_user}","gists_url":"https://api.github.com/users/christophe12sopra/gists{/gist_id}","starred_url":"https://api.github.com/users/christophe12sopra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/christophe12sopra/subscriptions","organizations_url":"https://api.github.com/users/christophe12sopra/orgs","repos_url":"https://api.github.com/users/christophe12sopra/repos","events_url":"https://api.github.com/users/christophe12sopra/events{/privacy}","received_events_url":"https://api.github.com/users/christophe12sopra/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-05-16T07:52:10Z","updated_at":"2016-05-16T09:05:19Z","closed_at":null,"body":"hello. \r\n\r\nI have one object BO with complex properties (others objects)\r\nI map this BO object to another DTO object\r\nAfter, I map the DTO object to the existing BO Object\r\nI would like to retrieve the same memory reference for BO object and the properties in BO object.\r\nBO Object has the same memory reference but the objects in BO object properties have differents references.\r\nHow can explain at Automapper use the same cluster objects ?\r\nExemple for my problem : \r\n\r\nusing System;\r\nusing Microsoft.VisualStudio.TestTools.UnitTesting;\r\nusing System.Collections.Generic;\r\nusing AutoMapper;\r\n\r\nnamespace UIModelTest\r\n{\r\n    [TestClass]\r\n    public class NestedObjectMapping\r\n    {\r\n        [TestMethod]\r\n        public void TestMethod1()\r\n        {\r\n            IMappingExpression<Docu, DocuDTO> imi = Mapper.CreateMap<Docu, DocuDTO>()\r\n            .ConstructUsing((ResolutionContext rc) => (new DocuDTO())).IncludeBase<Common, CommonDTO>();\r\n            imi.ReverseMap();//.ConstructUsing((ResolutionContext rc) => new Docu());\r\n            IMappingExpression<Coor, CoorDTO> imi2 = Mapper.CreateMap<Coor, CoorDTO>()\r\n            .ConstructUsing((ResolutionContext rc) => (new CoorDTO()));\r\n            imi2.ReverseMap();//.ConstructUsing((ResolutionContext rc) => new Coor());\r\n            IMappingExpression<Comp, CompDTO> imi3 = Mapper.CreateMap<Comp, CompDTO>()\r\n            .ConstructUsing((ResolutionContext rc) => (new CompDTO()));\r\n            imi3.ReverseMap();//.ConstructUsing((ResolutionContext rc) => new Comp());\r\n            IMappingExpression<Common, CommonDTO> imi4 = Mapper.CreateMap<Common, CommonDTO>()\r\n            .ConstructUsing((ResolutionContext rc) => (new CommonDTO()));\r\n            imi4.ReverseMap();//.ConstructUsing((ResolutionContext rc) => new Common());\r\n\r\n            Comp unComposant1 = new Comp();\r\n            unComposant1.id = \"COMP1\";\r\n            unComposant1.description = \"THE comp 1\";\r\n            Comp unComposant2 = new Comp();\r\n            unComposant2.id = \"COMP2\";\r\n            unComposant2.description = \"THE comp 2\";\r\n            Coor coor1 = new Coor();\r\n            coor1.id = \"COOR1\";\r\n            coor1.valCoor = 1;\r\n            coor1.leComp = unComposant1;\r\n            Coor coor2 = new Coor();\r\n            coor2.id = \"COOR2\";\r\n            coor2.valCoor = 2;\r\n            coor2.leComp = unComposant2;\r\n            Docu document = new Docu();\r\n            document.coors = new List<Coor>();\r\n            document.coors.Add(coor1);\r\n            document.coors.Add(coor2);\r\n            document.id = \"DOCU\";\r\n            document.val = 9;\r\n\r\n            DocuDTO documentDTO = Mapper.Map<Docu, DocuDTO>(document);\r\n\r\n            // please note the reference of each Object unComposant1, unComposant2, unComposant3, coor1, coor2, document\r\n\r\n            Mapper.Map<DocuDTO, Docu>(documentDTO, document);\r\n\r\n            // please compare the reference of each Object unComposant1, unComposant2, unComposant3, coor1, coor2, document with old references see above\r\n\r\n            // my problem : \r\n            // object documentDTO mapping in existing object document -> OK\r\n            // but the properties of object documentDTO don't mapping in existing properties object document\r\n            // why ?\r\n            // What is the way to reach the goal ?\r\n        }\r\n\r\n    }\r\n\r\n    public class Common\r\n    {\r\n\r\n    }\r\n    \r\n    public class Docu : Common\r\n    {\r\n        public String id; \r\n        public int val;\r\n        public IList<Coor> coors;\r\n    }\r\n\r\n    public class Coor\r\n    {\r\n        public String id;\r\n        public int valCoor;\r\n        public Comp leComp;\r\n    }\r\n\r\n    public class Comp\r\n    {\r\n        public String id;\r\n        public String description;\r\n    }\r\n\r\n    public class CommonDTO\r\n    {\r\n\r\n    }\r\n\r\n    public class DocuDTO : CommonDTO\r\n    {\r\n        public String id;\r\n        public int val;\r\n        public IList<CoorDTO> coors;\r\n    }\r\n\r\n    public class CoorDTO\r\n    {\r\n        public String id;\r\n        public int valCoor;\r\n        public CompDTO leComp;\r\n    }\r\n\r\n    public class CompDTO\r\n    {\r\n        public String id;\r\n        public String description;\r\n    }\r\n}\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/comments/219381168","html_url":"https://github.com/AutoMapper/AutoMapper/issues/1276#issuecomment-219381168","issue_url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/1276","id":219381168,"user":{"login":"lbargaoanu","id":4517428,"avatar_url":"https://avatars.githubusercontent.com/u/4517428?v=3","gravatar_id":"","url":"https://api.github.com/users/lbargaoanu","html_url":"https://github.com/lbargaoanu","followers_url":"https://api.github.com/users/lbargaoanu/followers","following_url":"https://api.github.com/users/lbargaoanu/following{/other_user}","gists_url":"https://api.github.com/users/lbargaoanu/gists{/gist_id}","starred_url":"https://api.github.com/users/lbargaoanu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lbargaoanu/subscriptions","organizations_url":"https://api.github.com/users/lbargaoanu/orgs","repos_url":"https://api.github.com/users/lbargaoanu/repos","events_url":"https://api.github.com/users/lbargaoanu/events{/privacy}","received_events_url":"https://api.github.com/users/lbargaoanu/received_events","type":"User","site_admin":false},"created_at":"2016-05-16T09:05:19Z","updated_at":"2016-05-16T09:05:19Z","body":"That doesn't even compile with the MyGet build. Test it with the MyGet build and if the problem remains, post the updated code."}}