Created
June 1, 2011 07:09
-
-
Save rvlieshout/1001916 to your computer and use it in GitHub Desktop.
MappedCommandToAggregateRootMethodOrConstructor Execute adjustment?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Executes the command. | |
/// </summary> | |
/// <param name="command">The command to execute.</param> | |
/// <returns>The aggregateroot of type <typeparamref name="TAggRoot"/> on which we executed the command.</returns> | |
void ICommandExecutor<TCommand>.Execute(TCommand command) | |
{ | |
var factory = NcqrsEnvironment.Get<IUnitOfWorkFactory>(); | |
using (var work = factory.CreateUnitOfWork(command.CommandIdentifier)) | |
{ | |
var aggregateroot = _aggregaterootfetchfunc(_getidfromcommandfunc(command), command.KnownVersion); | |
if (aggregateroot == null) | |
{ | |
aggregateroot = _aggregaterootcreatorfunc(command); | |
} | |
else | |
{ | |
_mappedmethodforcommandfunc(command, aggregateroot); | |
} | |
work.Accept(); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Executes the command. | |
/// </summary> | |
/// <param name="command">The command to execute.</param> | |
/// <returns>The aggregateroot of type <typeparamref name="TAggRoot"/> on which we executed the command.</returns> | |
void ICommandExecutor<TCommand>.Execute(TCommand command) | |
{ | |
var factory = NcqrsEnvironment.Get<IUnitOfWorkFactory>(); | |
using (var work = factory.CreateUnitOfWork(command.CommandIdentifier)) | |
{ | |
var aggregateroot = _aggregaterootfetchfunc(_getidfromcommandfunc(command), command.KnownVersion) ?? _aggregaterootcreatorfunc(command); | |
_mappedmethodforcommandfunc(command, aggregateroot); | |
work.Accept(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment