/// <summary> /// Locates the aggregate stored in <paramref name="store"/>, identified by <paramref name="id"/>. /// </summary> /// <param name="store">Event store to query.</param> /// <param name="id">Id of the aggregate.</param> /// <param name="version">Version of the aggregate, or <c>null</c> for the latest version.</param> /// <param name="cancellationToken">Cancellation token</param> /// <returns> /// The constructed aggregate, or <c>null</c> if the stream does not exist in <paramref name="store"/>. /// </returns> public static Task <TAggregate?> FromAsync( IEventStore store, TIdentity id, long?version = null, CancellationToken cancellationToken = default ) => store.AggregateAsync(id, GetConfiguration(), version, cancellationToken);
public async Task <TEntity> FindByIdAsync(object id, CancellationToken cancellationToken = default) { if (!(id is Guid guidId)) { throw new NotSupportedException("Id of the Event Sourced aggregate has to be Guid"); } return((await documentSession.Events.FetchStreamStateAsync(guidId, cancellationToken)) != null ? await eventStore.AggregateAsync <TEntity>(guidId, cancellationToken : cancellationToken) : null); }
public async Task <TEntity> GetByIdAsync <TEntity>(object id, CancellationToken cancellationToken = default(CancellationToken)) where TEntity : class, new() { if (!(id is Guid guidId)) { throw new NotSupportedException("Id of the Event Sourced aggregate has to be Guid"); } if ((await documentSession.Events.FetchStreamStateAsync((Guid)id)) == null) { return(null); } return(await eventStore.AggregateAsync <TEntity>(guidId, cancellationToken)); }
/// <inheritdoc /> public Task <TAggregate?> AggregateAsync( TIdentity id, long?version = null, CancellationToken cancellationToken = default ) => _store.AggregateAsync(id, Configuration, version, cancellationToken);
public static Task <Goat> FromAsync(IEventStore store, Guid id) { return(store.AggregateAsync(id, Configuration)); }
public static Task <Case?> FromAsync(IEventStore store, CaseId id) { return(store.AggregateAsync(id, Configuration)); }