Exemple #1
0
        private void AppendAverageDerivedProjection(AggregationProjection averageProjection)
        {
            String innerExpression = averageProjection.GetInnerExpression();
            String countAlias      = DerivedColumn.Get(DerivedColumnEnum.AVG_COUNT_ALIAS).GetDerivedColumnAlias(aggregationAverageDerivedColumnCount);
            AggregationProjection countProjection = new AggregationProjection(AggregationTypeEnum.COUNT, innerExpression, countAlias);
            String sumAlias = DerivedColumn.Get(DerivedColumnEnum.AVG_SUM_ALIAS).GetDerivedColumnAlias(aggregationAverageDerivedColumnCount);
            AggregationProjection sumProjection = new AggregationProjection(AggregationTypeEnum.SUM, innerExpression, sumAlias);

            averageProjection.GetDerivedAggregationProjections().Add(countProjection);
            averageProjection.GetDerivedAggregationProjections().Add(sumProjection);
            aggregationAverageDerivedColumnCount++;
        }
Exemple #2
0
        private AggregationDistinctProjection CreateProjection(string sql, AggregationDistinctProjectionSegment projectionSegment)
        {
            var innerExpression = sql.SubStringWithEndIndex(projectionSegment.GetInnerExpressionStartIndex(), projectionSegment.GetStopIndex() + 1);
            var alias           = projectionSegment.GetAlias() ?? DerivedColumn.Get(DerivedColumnEnum.AGGREGATION_DISTINCT_DERIVED).GetDerivedColumnAlias(aggregationDistinctDerivedColumnCount++);
            AggregationDistinctProjection result = new AggregationDistinctProjection(
                projectionSegment.GetStartIndex(), projectionSegment.GetStopIndex(), projectionSegment.GetAggregationType(), innerExpression, alias, projectionSegment.GetDistinctExpression());

            if (AggregationTypeEnum.AVG == result.GetAggregationType())
            {
                AppendAverageDistinctDerivedProjection(result);
            }
            return(result);
        }
Exemple #3
0
        private void AppendAverageDistinctDerivedProjection(AggregationDistinctProjection averageDistinctProjection)
        {
            var innerExpression         = averageDistinctProjection.GetInnerExpression();
            var distinctInnerExpression = averageDistinctProjection.GetDistinctInnerExpression();
            var countAlias = DerivedColumn.Get(DerivedColumnEnum.AVG_COUNT_ALIAS).GetDerivedColumnAlias(aggregationAverageDerivedColumnCount);
            AggregationDistinctProjection countDistinctProjection = new AggregationDistinctProjection(0, 0, AggregationTypeEnum.COUNT, innerExpression, countAlias, distinctInnerExpression);
            var sumAlias = DerivedColumn.Get(DerivedColumnEnum.AVG_SUM_ALIAS).GetDerivedColumnAlias(aggregationAverageDerivedColumnCount);
            AggregationDistinctProjection sumDistinctProjection = new AggregationDistinctProjection(0, 0, AggregationTypeEnum.SUM, innerExpression, sumAlias, distinctInnerExpression);

            averageDistinctProjection.GetDerivedAggregationProjections().Add(countDistinctProjection);
            averageDistinctProjection.GetDerivedAggregationProjections().Add(sumDistinctProjection);
            aggregationAverageDerivedColumnCount++;
        }
 private ICollection <IProjection> GetDerivedOrderByColumns(ICollection <IProjection> projections, OrderByContext orderByContext, SelectCommand selectCommand)
 {
     return(GetDerivedOrderColumns(projections, orderByContext.GetItems(), DerivedColumn.Get(DerivedColumnEnum.ORDER_BY_ALIAS), selectCommand));
 }
 private ICollection <IProjection> GetDerivedGroupByColumns(ICollection <IProjection> projections, GroupByContext groupByContext, SelectCommand selectCommand)
 {
     return(GetDerivedOrderColumns(projections, groupByContext.GetItems(), DerivedColumn.Get(DerivedColumnEnum.GROUP_BY_ALIAS), selectCommand));
 }