Replies: 1 comment 1 reply
-
Hi @0xced , |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm trying to register an
IDbContextFactory<MyContext>
from within a command interceptor to make it available to my commands.Here's my interceptor:
And here's how I'm using it:
Unfortunately, this doesn't work because the interceptor is called after the type resolver is built.
To workaround this issue I built an abstract
AsyncCommand<TSettings>
base class with aprotected IDbContextFactory<MyContext> DbContextFactory { get; private set; } = null!;
property initialized at the very beginning of theExecuteAsync
method. It's not a bad solution but I feel that injecting theIDbContextFactory<MyContext>
from the interceptor would have been a cleaner solution.Is there another way that I could inject my
IDbContextFactory<MyContext>
without a base class? Would it be possible to call the interceptor before the type resolver is built? (It looks like a chicken and egg problem though. 😕)Beta Was this translation helpful? Give feedback.
All reactions