/// <summary> /// Loads all the domain events for the specific aggregate root from the storage. /// </summary> /// <param name="aggregateRootType">The type of the aggregate root.</param> /// <param name="id">The identifier of the aggregate root.</param> /// <param name="version">The version number.</param> /// <returns>A list of domain events for the specific aggregate root which occur just after /// the given version number.</returns> public IEnumerable <IDomainEvent <TSourceId> > LoadEvents(Type aggregateRootType, TSourceId id, long version) { var sort = new PropertyBag(); sort.AddSort <long>("Version"); var aggregateRootTypeName = aggregateRootType.AssemblyQualifiedName; ISpecification <DomainEventDataObject <TSourceId> > specification = Specification <DomainEventDataObject <TSourceId> > .Eval(p => p.SourceId.Equals(id) && p.AssemblyQualifiedSourceType == aggregateRootTypeName && p.Version > version); return(_storage.Select <DomainEventDataObject <TSourceId> >(specification, sort, SortOrder.Ascending).Select(p => _domainEventSerializer.ToDomainEvent(p))); }
/// <summary> /// Loads all the domain events for the specific aggregate root from the storage. /// </summary> /// <param name="aggregateRootType">The type of the aggregate root.</param> /// <param name="id">The identifier of the aggregate root.</param> /// <param name="version">The version number.</param> /// <returns>A list of domain events for the specific aggregate root which occur just after /// the given version number.</returns> public IEnumerable <IDomainEvent> LoadEvents(Type aggregateRootType, Guid id, long version) { PropertyBag sort = new PropertyBag(); sort.AddSort <long>("Version"); var aggregateRootTypeName = aggregateRootType.AssemblyQualifiedName; ISpecification <DomainEventDataObject> specification = Specification <DomainEventDataObject> .Eval(p => p.SourceID == id && p.AssemblyQualifiedSourceType == aggregateRootTypeName && p.Version > version); return(storage.Select <DomainEventDataObject>(specification, sort, Apworks.Storage.SortOrder.Ascending).Select(p => p.ToDomainEvent())); }
/// <summary> /// Loads all the domain events for the specific aggregate root from the storage. /// </summary> /// <param name="aggregateRootType">The type of the aggregate root.</param> /// <param name="id">The identifier of the aggregate root.</param> /// <returns>A list of domain events for the specific aggregate root.</returns> public IEnumerable <IDomainEvent> LoadEvents(Type aggregateRootType, Guid id) { try { var sort = new PropertyBag(); sort.AddSort <long>("Version"); var aggregateRootTypeName = aggregateRootType.AssemblyQualifiedName; ISpecification <DomainEventDataObject> specification = Specification <DomainEventDataObject> .Eval(p => p.SourceId == id && p.AssemblyQualifiedSourceType == aggregateRootTypeName); return(_storage.Select <DomainEventDataObject>(specification, sort, SortOrder.Ascending).Select(p => _acDomain.ToDomainEvent(p))); } catch { throw; } }