{"action":"created","issue":{"url":"https://api.github.com/repos/jbogard/MediatR/issues/257","repository_url":"https://api.github.com/repos/jbogard/MediatR","labels_url":"https://api.github.com/repos/jbogard/MediatR/issues/257/labels{/name}","comments_url":"https://api.github.com/repos/jbogard/MediatR/issues/257/comments","events_url":"https://api.github.com/repos/jbogard/MediatR/issues/257/events","html_url":"https://github.com/jbogard/MediatR/issues/257","id":315368375,"node_id":"MDU6SXNzdWUzMTUzNjgzNzU=","number":257,"title":"[Question] Can IMediatR be registered as Singleton?","user":{"login":"benmccallum","id":157336,"node_id":"MDQ6VXNlcjE1NzMzNg==","avatar_url":"https://avatars0.githubusercontent.com/u/157336?v=4","gravatar_id":"","url":"https://api.github.com/users/benmccallum","html_url":"https://github.com/benmccallum","followers_url":"https://api.github.com/users/benmccallum/followers","following_url":"https://api.github.com/users/benmccallum/following{/other_user}","gists_url":"https://api.github.com/users/benmccallum/gists{/gist_id}","starred_url":"https://api.github.com/users/benmccallum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benmccallum/subscriptions","organizations_url":"https://api.github.com/users/benmccallum/orgs","repos_url":"https://api.github.com/users/benmccallum/repos","events_url":"https://api.github.com/users/benmccallum/events{/privacy}","received_events_url":"https://api.github.com/users/benmccallum/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":18,"created_at":"2018-04-18T07:50:17Z","updated_at":"2018-12-13T13:46:42Z","closed_at":"2018-04-19T02:58:34Z","author_association":"NONE","body":"I'm using a library that registers a type I define (that consumes IMediatr) as Singleton. Mediatr is registered in the `ServiceCollection` extensions as Scoped, so I'm getting an `InvalidOperationException: Cannot consume scoped service 'MediatR.IMediator' from singleton 'Xyz.Abc'` exception. \r\n\r\nI can circumvent the `ServiceCollection` extensions and do my own registration if need be, just wanted some advice on lifetime. \r\n\r\nFYI: This is for an ASP.NET Core web api style app.\r\n\r\nThanks!"},"comment":{"url":"https://api.github.com/repos/jbogard/MediatR/issues/comments/446973661","html_url":"https://github.com/jbogard/MediatR/issues/257#issuecomment-446973661","issue_url":"https://api.github.com/repos/jbogard/MediatR/issues/257","id":446973661,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0Njk3MzY2MQ==","user":{"login":"rwrz","id":2169309,"node_id":"MDQ6VXNlcjIxNjkzMDk=","avatar_url":"https://avatars1.githubusercontent.com/u/2169309?v=4","gravatar_id":"","url":"https://api.github.com/users/rwrz","html_url":"https://github.com/rwrz","followers_url":"https://api.github.com/users/rwrz/followers","following_url":"https://api.github.com/users/rwrz/following{/other_user}","gists_url":"https://api.github.com/users/rwrz/gists{/gist_id}","starred_url":"https://api.github.com/users/rwrz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rwrz/subscriptions","organizations_url":"https://api.github.com/users/rwrz/orgs","repos_url":"https://api.github.com/users/rwrz/repos","events_url":"https://api.github.com/users/rwrz/events{/privacy}","received_events_url":"https://api.github.com/users/rwrz/received_events","type":"User","site_admin":false},"created_at":"2018-12-13T13:46:42Z","updated_at":"2018-12-13T13:46:42Z","author_association":"NONE","body":"I have tried to use this \"CreateScope\" on my Singletons, well, worked. But since my Requests uses DbContext (with npgsql), I have problems connecting to database... for the first run, everything is ok, after that, I receive a lot of error from npgsql. So, I changed my graphql schema to Scoped.. and now everything works as expected. \r\nI wanted to make it work as Singleton, but couldn't make it happen."}}
{"actor":{"display_login":"rwrz"}}