Aggregate with injected dependency #269
Unanswered
fbjerggaard
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Have you added Regarding scoped registrations, Eventuous currently doesn't properly support it. I can't say how much work it would be to add request scopes to the service tbh, but, yes, it might be worth doing. |
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 want to inject a service in my Aggregate to be able to do some work before/after applying the changes and stumbled upon the example on how to register an aggregate with dependencies:
So far so good.
Now my aggregate looks like the following:
All good so far.
Add a parameterless constructor to the Payment aggregate - since otherwise the CommandService complains:
'Payment' must be a non-abstract type with a public parameterless constructor in order to use it as parameter 'TAggregate' in the generic class 'Eventuous.CommandService<TAggregate,TState,TId>'
And then. It doesn't work. My PaymentProcessor is null since it is being loaded throgh the parameterless constructor.
I can get it to load something in the constructor with the PaymentProcessor parameter (setting a breakpoint in both constructors), but I am not really sure why one is used over the other.
Another side-issue is that an aggregate is registered as a singleton by default while I need them as scoped - but that's a topic for when I get the default implementation to work :)
Beta Was this translation helpful? Give feedback.
All reactions