{"action":"created","issue":{"url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/2781","repository_url":"https://api.github.com/repos/AutoMapper/AutoMapper","labels_url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/2781/labels{/name}","comments_url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/2781/comments","events_url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/2781/events","html_url":"https://github.com/AutoMapper/AutoMapper/issues/2781","id":356671781,"node_id":"MDU6SXNzdWUzNTY2NzE3ODE=","number":2781,"title":"Automapper use Map and ProjectTo with parameters on same DTO","user":{"login":"Tbd19","id":37404025,"node_id":"MDQ6VXNlcjM3NDA0MDI1","avatar_url":"https://avatars0.githubusercontent.com/u/37404025?v=4","gravatar_id":"","url":"https://api.github.com/users/Tbd19","html_url":"https://github.com/Tbd19","followers_url":"https://api.github.com/users/Tbd19/followers","following_url":"https://api.github.com/users/Tbd19/following{/other_user}","gists_url":"https://api.github.com/users/Tbd19/gists{/gist_id}","starred_url":"https://api.github.com/users/Tbd19/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tbd19/subscriptions","organizations_url":"https://api.github.com/users/Tbd19/orgs","repos_url":"https://api.github.com/users/Tbd19/repos","events_url":"https://api.github.com/users/Tbd19/events{/privacy}","received_events_url":"https://api.github.com/users/Tbd19/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-09-04T06:40:31Z","updated_at":"2018-09-04T10:43:21Z","closed_at":null,"author_association":"NONE","body":"I have a DTO that requires a custom mapping based on a parameter.\r\n\r\nFor getting one DTO I use Map so the custom mapping that works is like this: \r\n    .ForMember(dest => dest.Field, opt => opt.ResolveUsing((src, dest, destMember, resContext) => dest.Field = (string)resContext.Items[\"param\"] == \"value\" ? src.Field1 : src.Field2))\r\nand the mapping is done like:\r\n    Mapper.Map<DTO>(entity, opts => opts.Items[\"param\"] = value);\r\n\r\nFor getting a list of DTO I use ProjectTo so the custom mapping that works is like this:\r\n    .ForMember(dest => dest.Field, opt => opt.MapFrom(src => param == \"value\" ? src.Field1 : src.Field2))\r\nand the mapping is done like:\r\n    queryable.ProjectTo<DTO>(Mapper.ConfigurationProvider, new Dictionary<string, object> { { \"param\", value } }\r\n\r\nBesides creating two DTOs is there a way to make both ProjectTo and Map use the same mapping? (I should mention that the mapping is done through a Profile)"},"comment":{"url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/comments/418321652","html_url":"https://github.com/AutoMapper/AutoMapper/issues/2781#issuecomment-418321652","issue_url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/2781","id":418321652,"node_id":"MDEyOklzc3VlQ29tbWVudDQxODMyMTY1Mg==","user":{"login":"Tbd19","id":37404025,"node_id":"MDQ6VXNlcjM3NDA0MDI1","avatar_url":"https://avatars0.githubusercontent.com/u/37404025?v=4","gravatar_id":"","url":"https://api.github.com/users/Tbd19","html_url":"https://github.com/Tbd19","followers_url":"https://api.github.com/users/Tbd19/followers","following_url":"https://api.github.com/users/Tbd19/following{/other_user}","gists_url":"https://api.github.com/users/Tbd19/gists{/gist_id}","starred_url":"https://api.github.com/users/Tbd19/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tbd19/subscriptions","organizations_url":"https://api.github.com/users/Tbd19/orgs","repos_url":"https://api.github.com/users/Tbd19/repos","events_url":"https://api.github.com/users/Tbd19/events{/privacy}","received_events_url":"https://api.github.com/users/Tbd19/received_events","type":"User","site_admin":false},"created_at":"2018-09-04T10:43:21Z","updated_at":"2018-09-04T10:43:21Z","author_association":"NONE","body":"Do you have an example on how to implement the support parameters of ProjectTo style in the Map also?"}}
{"actor":{"display_login":"Tbd19"}}