public T AggregateStream <T>(Guid streamId, int version = 0, DateTime?timestamp = null, T state = null) where T : class { ensureAsGuidStorage(); var inner = new EventQueryHandler <Guid>(_selector, streamId, version, timestamp, _store.Events.TenancyStyle, _tenant.TenantId); var aggregator = _store.Events.AggregateFor <T>(); var handler = new AggregationQueryHandler <T>(aggregator, inner, _session, state); var aggregate = _connection.Fetch(handler, null, null, _tenant); var assignment = _tenant.IdAssignmentFor <T>(); assignment.Assign(_tenant, aggregate, streamId); return(aggregate); }
public T AggregateStream <T>(Guid streamId, int version = 0, DateTime?timestamp = null) where T : class, new() { _tenant.EnsureStorageExists(typeof(EventStream)); var inner = new EventQueryHandler(_selector, streamId, version, timestamp); var aggregator = _store.Events.AggregateFor <T>(); var handler = new AggregationQueryHandler <T>(aggregator, inner, _session); var aggregate = _connection.Fetch(handler, null, null, _tenant); var assignment = _tenant.IdAssignmentFor <T>(); assignment.Assign(_tenant, aggregate, streamId); return(aggregate); }
public T AggregateStream <T>(Guid streamId, long version = 0, DateTime?timestamp = null, T state = null) where T : class { var events = FetchStream(streamId, version, timestamp); var aggregator = _store.Events.Projections.AggregatorFor <T>(); if (!events.Any()) { return(null); } var aggregate = aggregator.Build(events, _session, state); var assignment = _tenant.IdAssignmentFor <T>(); assignment.Assign(_tenant, aggregate, streamId); return(aggregate); }
public T AggregateStream <T>(Guid streamId, int version = 0, DateTime?timestamp = null, T state = null) where T : class { var selector = _store.Events.EnsureAsGuidStorage(_session); var inner = new EventQueryHandler <Guid>(selector, streamId, version, timestamp, _store.Events.TenancyStyle, _tenant.TenantId); var aggregator = _store.Events.Projections.AggregatorFor <T>(); var events = _session.ExecuteHandler(inner); if (!events.Any()) { return(null); } var aggregate = aggregator.Build(events, _session, state); var assignment = _tenant.IdAssignmentFor <T>(); assignment.Assign(_tenant, aggregate, streamId); return(aggregate); }
public IdAssignment <T> IdAssignmentFor <T>() { return(_inner.IdAssignmentFor <T>()); }