public AttemptToSaveAlreadyPersistedAggregateException(IEventStored aggregate)
     :base(
         string.Format("Instance of {0} with Id: {1} has already been persisted. To update it, load it from a session and modify it rather than attempting to call save",
                       aggregate.GetType().FullName, aggregate.Id))
 {
     
 }
Exemple #2
0
        public async Task <TAggregateRoot> GetAsync <TAggregateRoot>()
            where TAggregateRoot : class, IEventStored, new()
        {
            if (_trackedAggregate == null)
            {
                _trackedAggregate = await ExecutionHelper.ExecuteWithRetriesAsync(async ct =>
                {
                    var eventStream = await _stateManager.GetOrAddStateAsync("state", new TEventStream(), ct);
                    var aggregate   = new TAggregateRoot();
                    aggregate.Initialize(_eventController, eventStream.DomainEvents, UtcNowTimeProvider.Instance);
                    return(aggregate);
                }, 3, TimeSpan.FromSeconds(1), CancellationToken.None);
            }

            return((TAggregateRoot)_trackedAggregate);
        }
Exemple #3
0
 public AttemptToSaveAlreadyPersistedAggregateException(IEventStored aggregate)
     : base(
         string.Format("Instance of {0} with Id: {1} has already been persisted. To update it, load it from a session and modify it rather than attempting to call save",
                       aggregate.GetType().FullName, aggregate.Id))
 {
 }