コード例 #1
0
        /// <summary>
        ///     Finds and deserializes an aggregate the specified id, if any. If none exists, returns null.
        /// </summary>
        /// <param name="version">The version at which to retrieve the aggregate.</param>
        /// <param name="aggregateId">The id of the aggregate.</param>
        /// <returns>The deserialized aggregate, or null if none exists with the specified id.</returns>
        public TAggregate GetVersion(Guid aggregateId, long version)
        {
            var events = eventStream.UpToVersion(aggregateId.ToString(), version)
                         .Result
                         .ToArray();

            if (events.Any())
            {
                return(events.CreateAggregate <TAggregate>());
            }

            return(null);
        }