AggregateRoot

We found 10 examples in language CSharp for this search. You will see 37 fragments of code.

        [Fact]
        public async Task CommitsUncommittedEventsOnAggregateRootAfterSavingUncommittedEvents()
        {
            var aggregateRoot = new MyDynamicEventSourcedAggregateRoot(this.aggregateId);
            aggregateRoot.ChangeValue(11);
            aggregateRoot.ChangeValue(22);

            await this.testee.SaveAsync(aggregateRoot).ConfigureAwait(false);

            aggregateRoot.UncommittedEvents.Should().BeEmpty();
        }

        [Fact]
        public async Task BuiltInGlobalSnapshotStrategyHasAThresholdOf100()
        {
            const int Version = 100;
            var aggregateRoot = new MyDynamicEventSourcedAggregateRoot(this.aggregateId).WithVersion(Version);

            await this.testee.SaveAsync(aggregateRoot).ConfigureAwait(false);

            A.CallTo(() => this.eventStream.SaveSnapshotAsync(A<MySnapshot>.That.Matches(s => s.Version == Version))).MustHaveHappened();
        }

        [Fact]
        public async Task GlobalSnapshotStrategyDoesNotApply_WhenAggregateVersionIsZero()
        {
            var aggregateRoot = new MyDynamicEventSourcedAggregateRoot(this.aggregateId).WithVersion(0);

            await this.testee.SaveAsync(aggregateRoot).ConfigureAwait(false);

            A.CallTo(() => this.eventStream.SaveSnapshotAsync(A<ISnapshot>.Ignored)).MustNotHaveHappened();
        }

        [Fact]
        public async Task NoSnapshotStrategyApplies_WhenSnapshotIsNull()
        {
            var aggregateRoot = new OtherDynamicEventSourcedAggregateRoot().WithVersion(100);

            await this.testee.SaveAsync(aggregateRoot).ConfigureAwait(false);

            A.CallTo(() => this.eventStream.SaveSnapshotAsync(A<ISnapshot>.Ignored)).MustNotHaveHappened();
            A.CallTo(() => this.eventStream.SaveSnapshotAsync(null)).MustNotHaveHappened();
        }


        /// <inheritdoc />
        public Task SaveAsync<TAggregateRoot>(TAggregateRoot aggregateRoot) where TAggregateRoot : IEventSourcedAggregateRoot
        {
            return this.SaveAsync(aggregateRoot, new Dictionary<string, object>());
        }


        public bool Add(TAggregateRoot aggregateRoot)
        {
            this.currentRepositoryContextProvider.Current.RegisterAdded(this, aggregateRoot);

            return true;
        }

        public bool Update(TAggregateRoot aggregateRoot)
        {
            this.currentRepositoryContextProvider.Current.RegisterUpdated(this, aggregateRoot);

            return true;
        }

        public bool Delete(TAggregateRoot aggregateRoot)
        {
            this.currentRepositoryContextProvider.Current.RegisterDeleted(this, aggregateRoot);

            return true;
        }
        #endregion

        #region IUnitOfWorkRepository
        public void PersistentAdded(IAggregateRoot aggregateRoot) 
        {
            this.PersistAdded(aggregateRoot);
        }

        public void PersistentUpdate(IAggregateRoot aggregateRoot)
        {
            this.PersistUpdate(aggregateRoot);
        }

        public void PersistentDelete(IAggregateRoot aggregateRoot) 
        {
            this.PersistDelete(aggregateRoot);
        }


        /// <summary>
        /// Gets the entity.
        /// </summary>
        /// <param name="id">The id.</param>
        public virtual void GetEntity(TId id)
        {
            var aggregateRoot = _factory.GetById(id);
            if (aggregateRoot != null)
                OnActionStateNotification(aggregateRoot.State, aggregateRoot.Root);
            else
                OnEnityNotExistNotification(id);
        }

        /// <summary>
        /// Does the action.
        /// </summary>
        /// <param name="aggregateRoot">The aggregate root.</param>
        protected void DoAction(AggregateRoot<TEntity, TId> aggregateRoot)
        {
            if ((!string.IsNullOrEmpty(aggregateRoot.State)) && (_strategies.ContainsKey(aggregateRoot.State)))
            {
                _strategies[aggregateRoot.State].Invoke(aggregateRoot);
            }
        }

        /// <summary>
        /// Finds the entity.
        /// </summary>
        /// <param name="spec"> </param>
        /// <returns></returns>
        public TEntity FindEntity(object spec)
        {
            var aggregateRoot = Factory.FindEntity(spec);
            var findEntity = aggregateRoot != null ? aggregateRoot.Root : default(TEntity);
            return findEntity;
        }


        /// <summary>
        /// Gets the intermediate events.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="finalState">The final state.</param>
        /// <returns></returns>
        public IEnumerable<Type> GetIntermediateEvents(TId id, string finalState)
        {
            var aggregateRoot = Factory.GetById(id);
            return aggregateRoot != null ? aggregateRoot.GetIntermediateEvents(finalState) : null;
        }

        #endregion

        public abstract TRepositoryItem LockObject<TRepositoryItem>(TRepositoryItem obj)
            where TRepositoryItem : AggregateRoot;

        public void Add(TAggregateRoot aggregateRoot)
        => Data.Add(aggregateRoot);

        public TAggregateRoot AddAndReturn(TAggregateRoot aggregateRoot, bool autoExecute = true)
        {
            Data.Add(aggregateRoot);
            return aggregateRoot;
        }

        public Task<TAggregateRoot> AddAndReturnAsync(TAggregateRoot aggregateRoot, bool autoExecute = true, CancellationToken cancellationToken = default)
        {
            Data.Add(aggregateRoot);
            return Task.FromResult(aggregateRoot);
        }

        public Task AddAsync(TAggregateRoot aggregateRoot, CancellationToken cancellationToken = default)
        {
            Data.Add(aggregateRoot);
            return Task.CompletedTask;
        }

        public void Delete(TAggregateRoot aggregateRoot)
        => Data.Remove(aggregateRoot);

        public Task DeleteAsync(TAggregateRoot aggregateRoot, CancellationToken cancellationToken = default)
        {
            Data.Remove(aggregateRoot);
            return Task.CompletedTask;
        }


        /// <summary>
        /// 跟踪
        /// </summary>
        /// <param name="dbData"></param>
        /// <param name="newData"></param>
        /// <returns></returns>
        protected virtual (List<object> added, List<object> updated, List<object> removed) Tracking(TAggregateRoot dbData, TAggregateRoot newData)
        {
            return TrackingHelper.Tracking(dbData, newData);
        }

        /// <summary>
        /// 获取IQueryable
        /// </summary>
        /// <returns></returns>
        protected virtual IQueryable<TAggregateRoot> GetQuery()
        {
            return Db.GetIQueryable<TAggregateRoot>().AsTracking().AsSingleQuery();
        }

        /// <summary>
        /// 从数据库获取数据
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        protected virtual async Task<TAggregateRoot> GetDbData(TKey key)
        {
            return await GetQuery().Where($"{KeyField} == @0", key).AsTracking().FirstOrDefaultAsync();
        }

        /// <summary>
        /// 获取
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public virtual async Task<TAggregateRoot> Get(TKey key)
        {
            var dbData = await GetDbData(key);

            return dbData.DeepClone();
        }

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="aggregateRoot"></param>
        /// <returns></returns>
        public virtual async Task Add(TAggregateRoot aggregateRoot)
        {
            var dbData = aggregateRoot.DeepClone();
            await Db.InsertAsync(dbData, true);

            Tracking(aggregateRoot, dbData);
        }

        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="aggregateRoot"></param>
        /// <returns></returns>
        public virtual async Task Update(TAggregateRoot aggregateRoot)
        {
            var dbData = await GetDbData(aggregateRoot.Id);

            var (added, updated, removed) = Tracking(dbData, aggregateRoot);
            added.ForEach(aAdded =>
            {
                Db.Entry(aAdded).State = EntityState.Added;
            });

            await Db.SaveChangesAsync();

            Tracking(aggregateRoot, dbData);
        }


        protected override void DoDispose(bool dispose)
        {
            if (dispose)
            {
                if (this.IsCommited)
                {
                    this.context.Dispose();
                }
            }
        }

        protected override bool DoCommit()
        {
            try
            {
                foreach (IAggregateRoot aggregateRoot in this.RegisterAddedCollection.Keys)
                {
                    this.context.Set(aggregateRoot.GetType()).Add(aggregateRoot);
                }
                foreach (IAggregateRoot aggregateRoot in this.RegisterUpdatedCollection.Keys)
                {
                    this.context.Entry(aggregateRoot).State = EntityState.Modified;
                }
                foreach (IAggregateRoot aggregateRoot in this.RegisterDeleteCollection.Keys)
                {
                    this.context.Entry(aggregateRoot).State = EntityState.Deleted;
                }
                this.context.SaveChanges();

                return true;
            }
            catch (Exception ex)
            {
                throw new UnitOfWorkException(ex.ToDetailMessage());
            }
        }

using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations.Schema;
using Abp.Events.Bus;

namespace Abp.Domain.Entities
{
    public class AggregateRoot : AggregateRoot<int>, IAggregateRoot
    {

    }

    public class AggregateRoot<TPrimaryKey> : Entity<TPrimaryKey>, IAggregateRoot<TPrimaryKey>
    {
        [NotMapped]
        public virtual ICollection<IEventData> DomainEvents { get; }

        public AggregateRoot()
        {
            DomainEvents = new Collection<IEventData>();
        }
    }
}


        protected override void CorrelateMessages(ICorrelationConfig<PedidoSagaData> config)
        {
            config.Correlate<RealizarPedidoCommand>(m => m.AggregateRoot, d => d.Id);
            config.Correlate<PagamentoRealizadoEvent>(m => m.AggregateRoot, d => d.Id);
            config.Correlate<PedidoFinalizadoEvent>(m => m.AggregateRoot, d => d.Id);
            config.Correlate<PagamentoRecusadoEvent>(m => m.AggregateRoot, d => d.Id);
            config.Correlate<PedidoCanceladoEvent>(m => m.AggregateRoot, d => d.Id);
        }

        public Task Handle(RealizarPedidoCommand message)
        {
            //_bus.Send(new RealizarPedidoCommand{AggregateRoot = message.AggregateRoot}).Wait();
            // Realiza processamento de negocio!

            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("Pedido Realizado!");
            Console.ForegroundColor = ConsoleColor.Black;

            _bus.Publish(new PedidoRealizadoEvent { AggregateRoot = message.AggregateRoot }).Wait();
            Data.PedidoRealizado = true;

            ProcessoSaga();

            return Task.CompletedTask;
        }

        public Task Handle(PagamentoRealizadoEvent message)
        {
            //_bus.Send(new FinalizarPedidoCommand { AggregateRoot = message.AggregateRoot }).Wait();
            // Realiza processamento de negocio!

            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("Pagamento Realizado!");
            Console.ForegroundColor = ConsoleColor.Black;

            _bus.Publish(new PedidoFinalizadoEvent { AggregateRoot = message.AggregateRoot }).Wait();
            Data.PagamentoRealizado = true;

            ProcessoSaga();

            return Task.CompletedTask;
        }

        public Task Handle(PedidoFinalizadoEvent message)
        {
            Data.PedidoFinalizado = true;

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Pedido FINALIZADO!");
            Console.ForegroundColor = ConsoleColor.Black;

            ProcessoSaga();

            return Task.CompletedTask;
        }

        public Task Handle(PagamentoRecusadoEvent message)
        {
            //_bus.Send(new CancelarPedidoCommand { AggregateRoot = message.AggregateRoot }).Wait();
            // Realiza processamento de negocio!

            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Pagamento Recusado!");
            Console.ForegroundColor = ConsoleColor.Black;

            _bus.Publish(new PedidoCanceladoEvent() { AggregateRoot = message.AggregateRoot }).Wait();
            Data.PagamentoRealizado = false;

            ProcessoSaga();

            return Task.CompletedTask;
        }

        public Task Handle(PedidoCanceladoEvent message)
        {
            Data.PedidoCancelado = true;

            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Pedido CANCELADO!");
            Console.ForegroundColor = ConsoleColor.Black;

            ProcessoSaga();

            return Task.CompletedTask;
        }

Volo.Abp.Domain.Entities.AggregateRoot : IEntity, IAggregateRoot, IGeneratesDomainEvents, IHasExtraProperties, IHasConcurrencyStamp

Methods :

public ExtraPropertyDictionary get_ExtraProperties()
public String get_ConcurrencyStamp()
public Void set_ConcurrencyStamp(String value = )
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext = )
public IEnumerable<DomainEventRecord> GetLocalEvents()
public IEnumerable<DomainEventRecord> GetDistributedEvents()
public Void ClearLocalEvents()
public Void ClearDistributedEvents()
public String ToString()
public abstract Object[] GetKeys()
public Boolean EntityEquals(IEntity other = )
public Type GetType()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()

AggregateRoot

We found 10 examples in language CSharp for this search. You will see 41 fragments of code.

        [Fact]
        public async Task CommitsUncommittedEventsOnAggregateRootAfterSavingUncommittedEvents()
        {
            var aggregateRoot = new MyDynamicEventSourcedAggregateRoot(this.aggregateId);
            aggregateRoot.ChangeValue(11);
            aggregateRoot.ChangeValue(22);

            await this.testee.SaveAsync(aggregateRoot).ConfigureAwait(false);

            aggregateRoot.UncommittedEvents.Should().BeEmpty();
        }

        [Fact]
        public async Task BuiltInGlobalSnapshotStrategyHasAThresholdOf100()
        {
            const int Version = 100;
            var aggregateRoot = new MyDynamicEventSourcedAggregateRoot(this.aggregateId).WithVersion(Version);

            await this.testee.SaveAsync(aggregateRoot).ConfigureAwait(false);

            A.CallTo(() => this.eventStream.SaveSnapshotAsync(A<MySnapshot>.That.Matches(s => s.Version == Version))).MustHaveHappened();
        }

        [Fact]
        public async Task GlobalSnapshotStrategyDoesNotApply_WhenAggregateVersionIsZero()
        {
            var aggregateRoot = new MyDynamicEventSourcedAggregateRoot(this.aggregateId).WithVersion(0);

            await this.testee.SaveAsync(aggregateRoot).ConfigureAwait(false);

            A.CallTo(() => this.eventStream.SaveSnapshotAsync(A<ISnapshot>.Ignored)).MustNotHaveHappened();
        }

        [Fact]
        public async Task NoSnapshotStrategyApplies_WhenSnapshotIsNull()
        {
            var aggregateRoot = new OtherDynamicEventSourcedAggregateRoot().WithVersion(100);

            await this.testee.SaveAsync(aggregateRoot).ConfigureAwait(false);

            A.CallTo(() => this.eventStream.SaveSnapshotAsync(A<ISnapshot>.Ignored)).MustNotHaveHappened();
            A.CallTo(() => this.eventStream.SaveSnapshotAsync(null)).MustNotHaveHappened();
        }


        /// <inheritdoc />
        public Task SaveAsync<TAggregateRoot>(TAggregateRoot aggregateRoot) where TAggregateRoot : IEventSourcedAggregateRoot
        {
            return this.SaveAsync(aggregateRoot, new Dictionary<string, object>());
        }


        public bool Add(TAggregateRoot aggregateRoot)
        {
            this.currentRepositoryContextProvider.Current.RegisterAdded(this, aggregateRoot);

            return true;
        }

        public bool Update(TAggregateRoot aggregateRoot)
        {
            this.currentRepositoryContextProvider.Current.RegisterUpdated(this, aggregateRoot);

            return true;
        }

        public bool Delete(TAggregateRoot aggregateRoot)
        {
            this.currentRepositoryContextProvider.Current.RegisterDeleted(this, aggregateRoot);

            return true;
        }
        #endregion

        #region IUnitOfWorkRepository
        public void PersistentAdded(IAggregateRoot aggregateRoot) 
        {
            this.PersistAdded(aggregateRoot);
        }

        public void PersistentUpdate(IAggregateRoot aggregateRoot)
        {
            this.PersistUpdate(aggregateRoot);
        }

        public void PersistentDelete(IAggregateRoot aggregateRoot) 
        {
            this.PersistDelete(aggregateRoot);
        }


        /// <summary>
        /// Gets the entity.
        /// </summary>
        /// <param name="id">The id.</param>
        public virtual void GetEntity(TId id)
        {
            var aggregateRoot = _factory.GetById(id);
            if (aggregateRoot != null)
                OnActionStateNotification(aggregateRoot.State, aggregateRoot.Root);
            else
                OnEnityNotExistNotification(id);
        }

        /// <summary>
        /// Does the action.
        /// </summary>
        /// <param name="aggregateRoot">The aggregate root.</param>
        protected void DoAction(AggregateRoot<TEntity, TId> aggregateRoot)
        {
            if ((!string.IsNullOrEmpty(aggregateRoot.State)) && (_strategies.ContainsKey(aggregateRoot.State)))
            {
                _strategies[aggregateRoot.State].Invoke(aggregateRoot);
            }
        }

        /// <summary>
        /// Finds the entity.
        /// </summary>
        /// <param name="spec"> </param>
        /// <returns></returns>
        public TEntity FindEntity(object spec)
        {
            var aggregateRoot = Factory.FindEntity(spec);
            var findEntity = aggregateRoot != null ? aggregateRoot.Root : default(TEntity);
            return findEntity;
        }


        /// <summary>
        /// Gets the intermediate events.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="finalState">The final state.</param>
        /// <returns></returns>
        public IEnumerable<Type> GetIntermediateEvents(TId id, string finalState)
        {
            var aggregateRoot = Factory.GetById(id);
            return aggregateRoot != null ? aggregateRoot.GetIntermediateEvents(finalState) : null;
        }

        #endregion

        #region Protected Methods
        protected void ClearRegistrations()
        {
            _localNewCollection.Value.Clear();
            _localModifiedCollection.Value.Clear();
            _localDeletedCollection.Value.Clear();
        }
        #endregion

        public abstract TRepositoryItem LockObject<TRepositoryItem>(TRepositoryItem obj)
            where TRepositoryItem : AggregateRoot;

        public virtual void RegisterSaved<TRepositoryItem>(TRepositoryItem obj)
            where TRepositoryItem : AggregateRoot
        {
            var objId = obj.ID;
            if (string.IsNullOrEmpty(objId))
                throw new ArgumentException("The UniqueIdentifier of the object is empty.", "obj");

            if (_localDeletedCollection.Value.ContainsKey(objId))
                throw new InvalidOperationException("The object cannot be registered as a modified object since it was marked as deleted.");

            if (!_localModifiedCollection.Value.ContainsKey(objId) && !_localNewCollection.Value.ContainsKey(objId))
                _localModifiedCollection.Value.Add(objId, obj);

            _localCommitted.Value = false;
        }

        /// <summary>
        /// Registers a deleted object to the repository context.
        /// </summary>
        /// <typeparam name="TRepositoryItem">The type of the aggregate root.</typeparam>
        /// <param name="obj">The object to be registered.</param>
        public virtual void RegisterRemoved<TRepositoryItem>(TRepositoryItem obj)
            where TRepositoryItem : AggregateRoot
        {
            var objId = obj.ID;
            if (objId.Equals(string.Empty))
                throw new ArgumentException("The UniqueIdentifier of the object is empty.", "obj");

            if (_localNewCollection.Value.ContainsKey(objId))
            {
                if (_localNewCollection.Value.Remove(objId))
                    return;
            }

            bool removedFromModified = _localModifiedCollection.Value.Remove(objId);
            bool addedToDeleted = false;
            if (!_localDeletedCollection.Value.ContainsKey(objId))
            {
                _localDeletedCollection.Value.Add(objId, obj);
                addedToDeleted = true;
            }

            _localCommitted.Value = !(removedFromModified || addedToDeleted);
        }

        public void Dispose()
        {
            _localCommitted.Dispose();
            _localDeletedCollection.Dispose();
            _localModifiedCollection.Dispose();
            _localNewCollection.Dispose();
        }


        /// <summary>
        /// 跟踪
        /// </summary>
        /// <param name="dbData"></param>
        /// <param name="newData"></param>
        /// <returns></returns>
        protected virtual (List<object> added, List<object> updated, List<object> removed) Tracking(TAggregateRoot dbData, TAggregateRoot newData)
        {
            return TrackingHelper.Tracking(dbData, newData);
        }

        /// <summary>
        /// 获取IQueryable
        /// </summary>
        /// <returns></returns>
        protected virtual IQueryable<TAggregateRoot> GetQuery()
        {
            return Db.GetIQueryable<TAggregateRoot>().AsTracking().AsSingleQuery();
        }

        /// <summary>
        /// 从数据库获取数据
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        protected virtual async Task<TAggregateRoot> GetDbData(TKey key)
        {
            return await GetQuery().Where($"{KeyField} == @0", key).AsTracking().FirstOrDefaultAsync();
        }

        /// <summary>
        /// 获取
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public virtual async Task<TAggregateRoot> Get(TKey key)
        {
            var dbData = await GetDbData(key);

            return dbData.DeepClone();
        }

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="aggregateRoot"></param>
        /// <returns></returns>
        public virtual async Task Add(TAggregateRoot aggregateRoot)
        {
            var dbData = aggregateRoot.DeepClone();
            await Db.InsertAsync(dbData, true);

            Tracking(aggregateRoot, dbData);
        }

        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="aggregateRoot"></param>
        /// <returns></returns>
        public virtual async Task Update(TAggregateRoot aggregateRoot)
        {
            var dbData = await GetDbData(aggregateRoot.Id);

            var (added, updated, removed) = Tracking(dbData, aggregateRoot);
            added.ForEach(aAdded =>
            {
                Db.Entry(aAdded).State = EntityState.Added;
            });

            await Db.SaveChangesAsync();

            Tracking(aggregateRoot, dbData);
        }

        public void Add(TAggregateRoot aggregateRoot)
        => Data.Add(aggregateRoot);

        public TAggregateRoot AddAndReturn(TAggregateRoot aggregateRoot, bool autoExecute = true)
        {
            Data.Add(aggregateRoot);
            return aggregateRoot;
        }

        public Task<TAggregateRoot> AddAndReturnAsync(TAggregateRoot aggregateRoot, bool autoExecute = true, CancellationToken cancellationToken = default)
        {
            Data.Add(aggregateRoot);
            return Task.FromResult(aggregateRoot);
        }

        public Task AddAsync(TAggregateRoot aggregateRoot, CancellationToken cancellationToken = default)
        {
            Data.Add(aggregateRoot);
            return Task.CompletedTask;
        }

        public void Delete(TAggregateRoot aggregateRoot)
        => Data.Remove(aggregateRoot);

        public Task DeleteAsync(TAggregateRoot aggregateRoot, CancellationToken cancellationToken = default)
        {
            Data.Remove(aggregateRoot);
            return Task.CompletedTask;
        }


        protected override void DoDispose(bool dispose)
        {
            if (dispose)
            {
                if (this.IsCommited)
                {
                    this.context.Dispose();
                }
            }
        }

        protected override bool DoCommit()
        {
            try
            {
                foreach (IAggregateRoot aggregateRoot in this.RegisterAddedCollection.Keys)
                {
                    this.context.Set(aggregateRoot.GetType()).Add(aggregateRoot);
                }
                foreach (IAggregateRoot aggregateRoot in this.RegisterUpdatedCollection.Keys)
                {
                    this.context.Entry(aggregateRoot).State = EntityState.Modified;
                }
                foreach (IAggregateRoot aggregateRoot in this.RegisterDeleteCollection.Keys)
                {
                    this.context.Entry(aggregateRoot).State = EntityState.Deleted;
                }
                this.context.SaveChanges();

                return true;
            }
            catch (Exception ex)
            {
                throw new UnitOfWorkException(ex.ToDetailMessage());
            }
        }

using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations.Schema;
using Abp.Events.Bus;

namespace Abp.Domain.Entities
{
    public class AggregateRoot : AggregateRoot<int>, IAggregateRoot
    {

    }

    public class AggregateRoot<TPrimaryKey> : Entity<TPrimaryKey>, IAggregateRoot<TPrimaryKey>
    {
        [NotMapped]
        public virtual ICollection<IEventData> DomainEvents { get; }

        public AggregateRoot()
        {
            DomainEvents = new Collection<IEventData>();
        }
    }
}


        protected override void CorrelateMessages(ICorrelationConfig<PedidoSagaData> config)
        {
            config.Correlate<RealizarPedidoCommand>(m => m.AggregateRoot, d => d.Id);
            config.Correlate<PagamentoRealizadoEvent>(m => m.AggregateRoot, d => d.Id);
            config.Correlate<PedidoFinalizadoEvent>(m => m.AggregateRoot, d => d.Id);
            config.Correlate<PagamentoRecusadoEvent>(m => m.AggregateRoot, d => d.Id);
            config.Correlate<PedidoCanceladoEvent>(m => m.AggregateRoot, d => d.Id);
        }

        public Task Handle(RealizarPedidoCommand message)
        {
            //_bus.Send(new RealizarPedidoCommand{AggregateRoot = message.AggregateRoot}).Wait();
            // Realiza processamento de negocio!

            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("Pedido Realizado!");
            Console.ForegroundColor = ConsoleColor.Black;

            _bus.Publish(new PedidoRealizadoEvent { AggregateRoot = message.AggregateRoot }).Wait();
            Data.PedidoRealizado = true;

            ProcessoSaga();

            return Task.CompletedTask;
        }

        public Task Handle(PagamentoRealizadoEvent message)
        {
            //_bus.Send(new FinalizarPedidoCommand { AggregateRoot = message.AggregateRoot }).Wait();
            // Realiza processamento de negocio!

            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine("Pagamento Realizado!");
            Console.ForegroundColor = ConsoleColor.Black;

            _bus.Publish(new PedidoFinalizadoEvent { AggregateRoot = message.AggregateRoot }).Wait();
            Data.PagamentoRealizado = true;

            ProcessoSaga();

            return Task.CompletedTask;
        }

        public Task Handle(PedidoFinalizadoEvent message)
        {
            Data.PedidoFinalizado = true;

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine("Pedido FINALIZADO!");
            Console.ForegroundColor = ConsoleColor.Black;

            ProcessoSaga();

            return Task.CompletedTask;
        }

        public Task Handle(PagamentoRecusadoEvent message)
        {
            //_bus.Send(new CancelarPedidoCommand { AggregateRoot = message.AggregateRoot }).Wait();
            // Realiza processamento de negocio!

            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Pagamento Recusado!");
            Console.ForegroundColor = ConsoleColor.Black;

            _bus.Publish(new PedidoCanceladoEvent() { AggregateRoot = message.AggregateRoot }).Wait();
            Data.PagamentoRealizado = false;

            ProcessoSaga();

            return Task.CompletedTask;
        }

        public Task Handle(PedidoCanceladoEvent message)
        {
            Data.PedidoCancelado = true;

            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine("Pedido CANCELADO!");
            Console.ForegroundColor = ConsoleColor.Black;

            ProcessoSaga();

            return Task.CompletedTask;
        }

Volo.Abp.Domain.Entities.AggregateRoot<TKey> : IEntity, IEntity

Methods :

public ExtraPropertyDictionary get_ExtraProperties()
public String get_ConcurrencyStamp()
public Void set_ConcurrencyStamp(String value = )
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext = )
public IEnumerable<DomainEventRecord> GetLocalEvents()
public IEnumerable<DomainEventRecord> GetDistributedEvents()
public Void ClearLocalEvents()
public Void ClearDistributedEvents()
public TKey get_Id()
public Object[] GetKeys()
public String ToString()
public Boolean EntityEquals(IEntity other = )
public Type GetType()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()

Other methods