{"action":"created","issue":{"url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/2905","repository_url":"https://api.github.com/repos/AutoMapper/AutoMapper","labels_url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/2905/labels{/name}","comments_url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/2905/comments","events_url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/2905/events","html_url":"https://github.com/AutoMapper/AutoMapper/issues/2905","id":386292516,"node_id":"MDU6SXNzdWUzODYyOTI1MTY=","number":2905,"title":"Question > Scoping Profiles","user":{"login":"ckapatch","id":855721,"node_id":"MDQ6VXNlcjg1NTcyMQ==","avatar_url":"https://avatars1.githubusercontent.com/u/855721?v=4","gravatar_id":"","url":"https://api.github.com/users/ckapatch","html_url":"https://github.com/ckapatch","followers_url":"https://api.github.com/users/ckapatch/followers","following_url":"https://api.github.com/users/ckapatch/following{/other_user}","gists_url":"https://api.github.com/users/ckapatch/gists{/gist_id}","starred_url":"https://api.github.com/users/ckapatch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ckapatch/subscriptions","organizations_url":"https://api.github.com/users/ckapatch/orgs","repos_url":"https://api.github.com/users/ckapatch/repos","events_url":"https://api.github.com/users/ckapatch/events{/privacy}","received_events_url":"https://api.github.com/users/ckapatch/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-11-30T18:04:39Z","updated_at":"2018-11-30T18:23:07Z","closed_at":null,"author_association":"NONE","body":"Hello everyone,\r\n\r\nWe're using two of Jimmy's great tools: AutoMapper and Mediatr.\r\n\r\nWe've adopted a structure in which a command/query is completely self-contained in a parent class:\r\n```csharp\r\npublic class GetSomething\r\n{\r\n   public class Query : IRequest<Response> {}\r\n   public class Handler: IRequestHandler<Query, Response> {}\r\n   public class MappingProfile: Profile {}\r\n   public class Response {}\r\n}\r\n```\r\n\r\nInside the Handler, we inject IMapper which in our current implementation assumes that the root has registered the profiles. We want to ensure that only the Profile inside of the GetSomething is being used and not being done somewhere else. Because we use the assembly scanning feature we aren't certain that the profile in this class is the only one that is being used to construct the mapping profile. \r\n\r\nCan we scope the profile here? We were thinking something along the lines of:\r\n```csharp\r\npublic class Handler: IRequestHandler<Query, Response>\r\n{\r\n    private IMapper _mapper = new MapperConfiguration(cfg =>\r\n    {\r\n        cfg.CreateMap<Source, Destination>();\r\n    }).CreateMapper(); \r\n}\r\n```\r\n\r\nBut we're unsure if this would cause performance issues etc...\r\n\r\nAny guidance or suggestions would be fantastic. Thank you.\r\n"},"comment":{"url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/comments/443293751","html_url":"https://github.com/AutoMapper/AutoMapper/issues/2905#issuecomment-443293751","issue_url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/2905","id":443293751,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MzI5Mzc1MQ==","user":{"login":"lbargaoanu","id":4517428,"node_id":"MDQ6VXNlcjQ1MTc0Mjg=","avatar_url":"https://avatars2.githubusercontent.com/u/4517428?v=4","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":"2018-11-30T18:23:07Z","updated_at":"2018-11-30T18:23:07Z","author_association":"MEMBER","body":"You can do that, use MapperConfiguration as scope, but then you need to cache those per appdomain/process (not per request as in your code). But maybe what you want is that separation in your object model and then the AM configuration is not relevant anymore."}}
{"actor":{"display_login":"lbargaoanu"}}