コード例 #1
0
        ISagaQuery <TSaga> ISagaQueryFactory <TSaga, TMessage> .CreateQuery(ConsumeContext <TMessage> context)
        {
            Expression <Func <TSaga, bool> > expression = new SagaFilterExpressionConverter <TSaga, TMessage>(context.Message)
                                                          .Convert(_filterExpression);

            return(new SagaQuery <TSaga>(expression));
        }
コード例 #2
0
        public IEnumerable <Guid> Find(IConsumeContext <TMessage> context)
        {
            Expression <Func <TSaga, bool> > filter =
                new SagaFilterExpressionConverter <TSaga, TMessage>(context.Message).Convert(_filterExpression);

            var sagaFilter = new SagaFilter <TSaga>(filter);

            int count = 0;

            foreach (var sagaId in  _repository.Where(sagaFilter, x => x.CorrelationId))
            {
                yield return(sagaId);

                count++;
            }

            if (count == 0)
            {
                if (_policy.CanCreateInstance(context))
                {
                    yield return(_policy.GetNewSagaId(context));
                }
            }
        }