Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Classes are create your own scope every time #74

Open
fabioravila opened this issue Jun 29, 2021 · 0 comments
Open

[Question] Classes are create your own scope every time #74

fabioravila opened this issue Jun 29, 2021 · 0 comments

Comments

@fabioravila
Copy link

First I'm sorry if this isn't the place to ask this question.
And I'm also sorry if this is a dumb question

I have a question as to how some main classes manage the context scope.
I'll take as an example the classes from "CQRS.*.Dispatchers"
Each as this class on the 'publish/send/query' user a code as below

using var scope = _serviceFactory.CreateScope();
var handler = scope.ServiceProvider.GetRequiredService<ICommandHandler<T>>();
await handler.HandleAsync(command);

So my question is in the case of ASP.NET when a request is made, it has its scope.

So let's say we use a CommandHandler to process a request and this command handler also uses an EventDispatcher, i think this is a common example.

With the current code, there is 3 scopes creates individually for Request, CommandHandler and EventHandler?
And each of these scopes would be individual?
If for example we want to use a unique DbContext per request, wouldn't that be a problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant