Skip to content
This repository was archived by the owner on Feb 6, 2025. It is now read-only.
This repository was archived by the owner on Feb 6, 2025. It is now read-only.

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

@fabioravila

Description

@fabioravila

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions