AggregateRoot LoadAggregateRoot <TAggregateRoot>(string aggregateRootId, long globalSequenceNumber)
            where TAggregateRoot : class
        {
            var aggregateRootInfo = _aggregateRootRepository
                                    .Get <TAggregateRoot>(aggregateRootId, this, maxGlobalSequenceNumber: globalSequenceNumber);

            var frozen = new FrozenAggregateRootService(aggregateRootInfo, _realUnitOfWork);

            aggregateRootInfo.UnitOfWork = frozen;
            return(aggregateRootInfo);
        }
Example #2
0
        public TAggregateRoot Load <TAggregateRoot>(string aggregateRootId, long globalSequenceNumber) where TAggregateRoot : class
        {
            if (!_aggregateRootRepository.Exists(aggregateRootId, maxGlobalSequenceNumber: globalSequenceNumber))
            {
                throw new ArgumentException(string.Format("Aggregate root with ID {0} does not exist!", aggregateRootId), "aggregateRootId");
            }

            var aggregateRootInfo = _aggregateRootRepository
                                    .Get <TAggregateRoot>(aggregateRootId, this, maxGlobalSequenceNumber: globalSequenceNumber);

            var aggregateRoot = aggregateRootInfo;

            var frozen = new FrozenAggregateRootService(aggregateRootInfo, _realUnitOfWork);

            aggregateRoot.UnitOfWork = frozen;

            return(aggregateRoot as TAggregateRoot);
        }