public void produces_the_view_type() { var aggregator = new Aggregator <QuestParty>(); var projection = new AggregationProjection <QuestParty>(null, aggregator); projection.Produces.ShouldBe(typeof(QuestParty)); }
private IComparable GetAggregationValue(IStreamDataReader streamDataReader, AggregationProjection aggregationProjection) { object result = streamDataReader.GetValue(aggregationProjection.GetIndex()); ShardingAssert.Else(null == result || result is IComparable, "Aggregation value must implements Comparable"); return((IComparable)result); }
public void consumes_delegates_to_internal_aggregation() { var aggregator = new Aggregator <QuestParty>(); var projection = new AggregationProjection <QuestParty>(null, aggregator); projection.Consumes.ShouldHaveTheSameElementsAs(aggregator.EventTypes); }
public void produces_the_view_type() { var aggregator = new Aggregator<QuestParty>(); var projection = new AggregationProjection<QuestParty>(null, aggregator); projection.Produces.ShouldBe(typeof(QuestParty)); }
public void consumes_delegates_to_internal_aggregation() { var aggregator = new Aggregator<QuestParty>(); var projection = new AggregationProjection<QuestParty>(null, aggregator); projection.Consumes.ShouldHaveTheSameElementsAs(aggregator.EventTypes); }
public Aggregator <T> AggregateStreamsInlineWith <T>() where T : class, new() { var aggregator = AggregateFor <T>(); var finder = new AggregateFinder <T>(); var projection = new AggregationProjection <T>(finder, aggregator); Inlines.Add(projection); return(aggregator); }
private AggregationProjection CreateProjection(string sql, AggregationProjectionSegment projectionSegment) { var innerExpression = sql.SubStringWithEndIndex(projectionSegment.GetInnerExpressionStartIndex(), projectionSegment.GetStopIndex() + 1); AggregationProjection result = new AggregationProjection(projectionSegment.GetAggregationType(), innerExpression, projectionSegment.GetAlias()); if (AggregationTypeEnum.AVG == result.GetAggregationType()) { AppendAverageDerivedProjection(result); // TODO replace avg to constant, avoid calculate useless avg } return(result); }
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++; }