You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been using your TransactionCommandHandlerDecorator and I came across a small problem when using this in conjunction with a command that has a dependency on another command as it is creating a second transaction block for the other command when I want it to share the same transaction?
PublicClassCreateProcedureTemplateDetailQuestionTypeHandlerImplementsICommandHandler(OfCreateProcedureTemplateDetailQuestionTypeCommand)PrivateReadOnly_contextAsApplicationDBContextPrivateReadOnly_handlerAsICommandHandler(OfCreateProcedureTemplateDetailCommand)PublicSubNew(contextAsApplicationDBContext,handlerAsICommandHandler(OfCreateProcedureTemplateDetailCommand))_context=context_handler=handlerEndSubPublicSubHandle(commandAsCreateProcedureTemplateDetailQuestionTypeCommand)ImplementsICommandHandler(OfCreateProcedureTemplateDetailQuestionTypeCommand).Handle_handler.Handle(command.DetailCommand)'Do other stuff specific to this commandEndSubEndClass
But once I call handle inside of CreateProcedureTemplateDetailQuestionTypeHandler.Handle() I get an exception as it tries to create another transaction scope. What is the best way of dealing with this, should I just new up instance inside of the CreateProcedureTemplateDetailQuestionTypeHandler and not use DI for that case?
The text was updated successfully, but these errors were encountered:
ith a command that has a dependency on another command
This is the core of your problem. My advise is to treat commands as holistic abstractions. This means that command handlers should not depend on other command handlers, especially not within the context of the same abstraction. You should use a different abstraction when dealing with 'sub commands'. This could be as well a generic abstraction, or you use normal non-generic interfaces for them.
What I have done is created a ICommandStrategyHandler and this is to be used by my sub command and the ICommandHandler is still decorated by the transaction. My instance of ICommandHandler then has a dependency on the new interface for it's sub command. This seems to have sorted it, but was checking to see if this is what you meant? This means that every instance of ICommandHandler will use the transaction but the other interface won't.
Hi,
I've been using your
TransactionCommandHandlerDecorator
and I came across a small problem when using this in conjunction with a command that has a dependency on another command as it is creating a second transaction block for the other command when I want it to share the same transaction?Here is some code to demonstrate the problem.
But once I call handle inside of
CreateProcedureTemplateDetailQuestionTypeHandler.Handle()
I get an exception as it tries to create another transaction scope. What is the best way of dealing with this, should I just new up instance inside of theCreateProcedureTemplateDetailQuestionTypeHandler
and not use DI for that case?The text was updated successfully, but these errors were encountered: