/// <summary> /// Finds and deserializes an aggregate the specified id, if any. If none exists, returns null. /// </summary> /// <param name="aggregateId">The id of the aggregate.</param> /// <param name="asOfDate">The date at which the aggregate should be sourced.</param> /// <returns> /// The deserialized aggregate, or null if none exists with the specified id. /// </returns> public TAggregate GetAsOfDate(Guid aggregateId, DateTimeOffset asOfDate) { var events = eventStream.AsOfDate(aggregateId.ToString(), asOfDate) .Result .ToArray(); if (events.Any()) { return(events.CreateAggregate <TAggregate>()); } return(null); }