public async Task SendQuery <T>(ConsumeContext <T> context, ISagaQuery <TSaga> query, IPipe <SagaRepositoryQueryContext <TSaga, T> > next) where T : class { await _sagas.MarkInUse(context.CancellationToken).ConfigureAwait(false); using var repositoryContext = new InMemorySagaRepositoryContext <TSaga, T>(_sagas, _factory, context); var matchingInstances = _sagas.Where(query).Select(x => x.Instance.CorrelationId).ToList(); var queryContext = new DefaultSagaRepositoryQueryContext <TSaga, T>(repositoryContext, matchingInstances); await next.Send(queryContext).ConfigureAwait(false); }
public async Task SendQuery <T>(ConsumeContext <T> context, ISagaQuery <TSaga> query, IPipe <SagaRepositoryQueryContext <TSaga, T> > next) where T : class { IEnumerable <TSaga> sagas = await _context.Container.GetItemLinqQueryable <TSaga>() .Where(query.FilterExpression) .QueryAsync(context.CancellationToken) .ConfigureAwait(false); var repositoryContext = new CosmosSagaRepositoryContext <TSaga, T>(_context, context, _factory); var queryContext = new DefaultSagaRepositoryQueryContext <TSaga, T>(repositoryContext, sagas.Select(x => x.CorrelationId).ToList()); await next.Send(queryContext).ConfigureAwait(false); }