예제 #1
0
        public void SetUp()
        {
            _querySource      = ExpressionHelper.CreateMainFromClause_Int();
            _sourceExpression = new QuerySourceReferenceExpression(_querySource);

            _func           = CreateFunc <int, int, int> ((total, i) => total + i);
            _resultOperator = new AggregateResultOperator(_func);
        }
예제 #2
0
        public void GetOutputDataInfo_Covariant()
        {
            var func           = CreateFunc <IComparable, IComparable, string> ((i1, i2) => null);
            var resultOperator = new AggregateResultOperator(func);

            var itemExpression = Expression.Constant("test");
            var input          = new StreamedSequenceInfo(typeof(string[]), itemExpression);
            var result         = resultOperator.GetOutputDataInfo(input);

            Assert.That(result, Is.InstanceOf(typeof(StreamedScalarValueInfo)));
            Assert.That(result.DataType, Is.SameAs(typeof(string)));
        }
예제 #3
0
        private T ExecuteAggregate <T>(QueryModel queryModel, AggregateResultOperator aggregate)
        {
            var valueProjector = ProjectorBuildingExpressionTreeVisitor <T> .BuildProjector(queryModel);

            var funcProjector = ProjectorBuildingExpressionTreeVisitor <T> .BuildAggregateProjector(queryModel, aggregate.Func);

            var resultItems = LoadData(queryModel);

            if (resultItems.Count == 0)
            {
                throw new DataException("For aggregate operation at least one result must be used");
            }
            var result = valueProjector(resultItems[0]);

            foreach (var item in resultItems.Skip(1))
            {
                result = funcProjector(item)(result);
            }
            return(result);
        }