Esempio n. 1
0
        static SamplingMethodsImplementations()
        {
            AggregationImplementations <SamplingImplementationBase> .RegisterAggregationImplementation("dayofweek", new DayOfWeekSampling());

            AggregationImplementations <SamplingImplementationBase> .RegisterAggregationImplementation("round", new RoundSampling());

            AggregationImplementations <SamplingImplementationBase> .RegisterAggregationImplementation("hourofday", new HourOfDaySampling());
        }
Esempio n. 2
0
        public void RegisterImplementation()
        {
            "dayofweek is registered".Given(
                () =>
            {
                AggregationImplementations <SamplingImplementationBase> .RegisterAggregationImplementation(
                    "dayofweek", new DayOfWeekSampling());
            });

            "when looking for the implementation".When(
                () =>
                AggregationImplementations <SamplingImplementationBase> .GetAggregationImplementation("dayofweek")
                .Should()
                .NotBeNull());
        }
Esempio n. 3
0
        public void LookForUnregisteredImplementation()
        {
            Exception exception = null;

            "dayofweek is registered".Given(
                () =>
            {
                AggregationImplementations <SamplingImplementationBase> .RegisterAggregationImplementation(
                    "dayofweek", new DayOfWeekSampling());
            });

            "when looking for the implementation".When(
                () => exception =
                    Record.Exception(() => AggregationImplementations <SamplingImplementationBase> .GetAggregationImplementation("xxx")));

            "unsupported Exception is thrown".Then(() => exception.Should().BeOfType <NotSupportedException>());
        }
Esempio n. 4
0
        /// <summary>
        /// Get the type to use for returning aggregation results in a group-by query.
        /// </summary>
        /// <param name="groupByTrasformation">The group by transformation.</param>
        /// <param name="keyType">The type of a group by key.</param>
        /// <returns>The new dynamic type.</returns>
        private Type GetAggregationResultProjectionType(ApplyGroupbyClause groupByTrasformation, Type keyType)
        {
            if (groupByTrasformation.Aggregate == null)
            {
                throw new ArgumentException("group by without aggregate");
            }
            var keyProperties             = new List <Tuple <Type, string> >();
            var aggregationImplementation = AggregationImplementations <AggregationImplementationBase> .GetAggregationImplementation(groupByTrasformation.Aggregate.AggregationMethod);

            var aliasType = aggregationImplementation.GetResultType(Context.ElementClrType, groupByTrasformation.Aggregate);

            keyProperties.Add(new Tuple <Type, string>(aliasType, groupByTrasformation.Aggregate.Alias));
            foreach (var prop in keyType.GetProperties())
            {
                if (prop.Name == "ComparerInstance")
                {
                    continue;
                }
                keyProperties.Add(new Tuple <Type, string>(prop.PropertyType, prop.Name));
            }

            return(AggregationTypesGenerator.CreateType(keyProperties.Distinct(new TypeStringTupleComapere()).ToList(), Context, true));
        }