示例#1
0
        private string GetAggFunctionUIText(string columnName, AggregationFunction aggFunction)
        {
            switch (aggFunction)
            {
            case AggregationFunction.Count:
                return("Count");

            case AggregationFunction.Total:
                return("Total " + columnName);

            case AggregationFunction.Minimum:
                return("Minimum " + columnName);

            case AggregationFunction.Maximum:
                return("Maximum " + columnName);

            case AggregationFunction.Average:
                return("Average " + columnName);

            case AggregationFunction.Median:
                return("Median " + columnName);

            default:
                return(columnName);
            }
        }
        private object AggregationFunctionAsString(AggregationFunction aggregationFunction)
        {
            var function = "";

            switch (aggregationFunction)
            {
            case AggregationFunction.count: function = "count"; break;

            case AggregationFunction.distinct: function = "distinct"; break;

            case AggregationFunction.integral: function = "integral"; break;

            case AggregationFunction.mean: function = "mean"; break;

            case AggregationFunction.median: function = "median"; break;

            case AggregationFunction.mode: function = "mode"; break;

            case AggregationFunction.spread: function = "spread"; break;

            case AggregationFunction.stddev: function = "stddev"; break;

            case AggregationFunction.sum: function = "sum"; break;
            }
            return(function);
        }
        /// <summary>
        /// Get SSAS aggregation function by name
        /// </summary>
        /// <param name="aggregationFunction"></param>
        /// <returns></returns>
        public static Microsoft.AnalysisServices.AggregationFunction GET_SSAS_AGGREGATION_FUNCTION_BY_NAME(String aggregationFunction)
        {
            AggregationFunction return_agg_fun = AggregationFunction.Sum;

            switch (aggregationFunction.ToLower())
            {
            case "lastnonempty":
                return_agg_fun = Microsoft.AnalysisServices.AggregationFunction.LastNonEmpty;
                break;

            case "averageofchildren":
                return_agg_fun = Microsoft.AnalysisServices.AggregationFunction.AverageOfChildren;
                break;

            case "count":
                return_agg_fun = Microsoft.AnalysisServices.AggregationFunction.Count;
                break;

            case "max":
                return_agg_fun = Microsoft.AnalysisServices.AggregationFunction.Max;
                break;

            case "min":
                return_agg_fun = Microsoft.AnalysisServices.AggregationFunction.Min;
                break;

            case "none":
                return_agg_fun = Microsoft.AnalysisServices.AggregationFunction.None;
                break;

            case "lastchild":
                return_agg_fun = Microsoft.AnalysisServices.AggregationFunction.LastChild;
                break;

            case "distinctcount":
                return_agg_fun = Microsoft.AnalysisServices.AggregationFunction.DistinctCount;
                break;

            case "byaccount":
                return_agg_fun = Microsoft.AnalysisServices.AggregationFunction.ByAccount;
                break;

            case "firstnonempty":
                return_agg_fun = Microsoft.AnalysisServices.AggregationFunction.FirstNonEmpty;
                break;

            case "sum":
                return_agg_fun = Microsoft.AnalysisServices.AggregationFunction.Sum;
                break;

            case "firstchild":
                return_agg_fun = Microsoft.AnalysisServices.AggregationFunction.FirstChild;
                break;

            default:
                break;
            }
            return(return_agg_fun);
        }
		public Aggregation (bool cacheResults, DataRow[] rows, AggregationFunction function, ColumnReference column)
		{
			this.cacheResults = cacheResults;
			this.rows = rows;
			this.column = column;
			this.function = function;
			this.result = null;
		}
示例#5
0
        }         // AddAnalysisItem

        private void AddAnalysisItem <T>(
            List <IAnalysisDataParameterInfo> target,
            ITimePeriod time,
            AggregationFunction function,
            T val
            )
        {
            target.Add(new AnalysisDataParameterInfo(time, val, function));
        } // AddAnalysisItem
示例#6
0
        /// <summary>
        /// Creates a multiple series chart from a IQueryable
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <typeparam name="TR"></typeparam>
        /// <param name="datasource"></param>
        /// <param name="label"></param>
        /// <param name="serie"></param>
        /// <param name="value"></param>
        /// <param name="aggregation"></param>
        /// <returns></returns>
        public static MultipleSerieChartResponse <TR> ProvideMultipleSerieChartResponse <T, TR>(
            this IQueryable <T> datasource, Expression <Func <T, string> > label, Expression <Func <T, string> > serie,
            Expression <Func <T, TR> > value, AggregationFunction aggregation = AggregationFunction.Sum)
        {
            // Series are filters
            var labelExpression = (label.Body as MemberExpression) ??
                                  ((MemberExpression)((UnaryExpression)label.Body).Operand);

            var serieExpression = (serie.Body as MemberExpression) ??
                                  ((MemberExpression)((UnaryExpression)serie.Body).Operand);

            var valueExpression = (value.Body as MemberExpression) ??
                                  ((MemberExpression)((UnaryExpression)value.Body).Operand);

            var dataSelector = GenerateDataSelector(aggregation, valueExpression);

            var series =
                datasource.OrderBy(serieExpression.Member.Name)
                .Select(serieExpression.Member.Name)
                .Cast <string>()
                .Distinct()
                .ToList();
            var labels =
                datasource.OrderBy(labelExpression.Member.Name)
                .Select(labelExpression.Member.Name)
                .Cast <string>()
                .Distinct()
                .ToList();

            var data = new List <List <decimal> >();

            foreach (var serieValue in series)
            {
                var subset = datasource.Where($"{serieExpression.Member.Name} == @0", serieValue)
                             .GroupBy(labelExpression.Member.Name, "it")
                             .Select($"new (it.Key as Label, {dataSelector} as Data)");

                var tempData     = subset.Select("Data").Cast <decimal>().ToList();
                var subsetLabels = subset.Select("Label").Cast <string>().ToList();

                var unkwnownLabels = labels.Except(subsetLabels);

                foreach (var index in unkwnownLabels.Select(item => labels.IndexOf(item)))
                {
                    tempData.Insert(index, 0);
                }

                data.Add(tempData);
            }

            return(new MultipleSerieChartResponse <TR>
            {
                Data = data.Select(x => x.Cast <TR>().ToArray()).ToArray(),
                Labels = labels.ToArray(),
                Series = series.ToArray()
            });
        }
示例#7
0
        private static string GenerateDataSelector(AggregationFunction aggregation, MemberExpression valueExpression)
        {
            if (aggregation == AggregationFunction.Count || aggregation == AggregationFunction.DistinctCount)
            {
                // TODO: DISTINCT is tricky and Ricky is a friend of mine
                return("COUNT()");
            }

            return($"{aggregation.ToString().ToUpper()}(it.{valueExpression.Member.Name})");
        }
示例#8
0
        }         // AppendFeedbacks

        private void AddAnalysisItem(
            List <IAnalysisDataParameterInfo> target,
            ITimePeriod time,
            AggregationFunction function,
            decimal numerator,
            decimal denominator
            )
        {
            AddAnalysisItem(target, time, function, denominator == 0 ? 0 : numerator / denominator);
        }         // AddAnalysisItem
示例#9
0
		public Aggregation (bool cacheResults, DataRow[] rows, AggregationFunction function, ColumnReference column)
		{
			this.cacheResults = cacheResults;
			this.rows = rows;
			this.column = column;
			this.function = function;
			this.result = null;
			if (cacheResults)
				RowChangeHandler = new DataRowChangeEventHandler (InvalidateCache);
		}
示例#10
0
 public Aggregation(bool cacheResults, DataRow[] rows, AggregationFunction function, ColumnReference column)
 {
     this.cacheResults = cacheResults;
     this.rows         = rows;
     this.column       = column;
     this.function     = function;
     this.result       = null;
     if (cacheResults)
     {
         RowChangeHandler = new DataRowChangeEventHandler(InvalidateCache);
     }
 }
示例#11
0
        public override string GetQuerySql()
        {
            var input1      = InputDict[Inputs[0]];
            var selectCols  = new List <string>();
            var groupByCols = new List <string>();

            for (var i = 0; i < GroupByColumnIndexes.Count; i++)
            {
                GroupByFunction groupByFunction = GroupByFunction.Date;

                if (i < GroupByFunctions.Count && GroupByFunctions[i].HasValue)
                {
                    groupByFunction = GroupByFunctions[i].Value;
                }

                var groupByStr = GetGroupByStr(GroupByColumnIndexes[i], groupByFunction);

                selectCols.Add(string.Format("{0} AS Column_{1:D}", groupByStr, selectCols.Count));

                groupByCols.Add(groupByStr);
            }

            for (var i = 0; i < AggFunctions.Count; i++)
            {
                AggregationFunction aggFunction = AggregationFunction.Count;

                if (i < AggFunctions.Count)
                {
                    aggFunction = AggFunctions[i];
                }

                var aggStr = GetAggStr(
                    aggFunction != AggregationFunction.Count ? AggColumnIndexes[i] : 0,
                    aggFunction);

                selectCols.Add(string.Format("{0} AS Column_{1:D}", aggStr, selectCols.Count));
            }

            var sql = string.Format("SELECT {0} FROM {1}", String.Join(",", selectCols), input1.GetDependencySql());

            if (GroupByColumnIndexes.Count > 0)
            {
                sql += string.Format(" GROUP BY {0}", String.Join(",", groupByCols));
            }

            return(sql);
        }
示例#12
0
        private static string GenerateDataSelector(AggregationFunction aggregation, MemberExpression valueExpression)
        {
            var dataSelector = string.Empty;

            if (aggregation == AggregationFunction.Count || aggregation == AggregationFunction.DistinctCount)
            {
                // TODO: DISTINCT is tricky and Ricky is a friend of mine
                dataSelector = "COUNT()";
            }
            else
            {
                dataSelector = string.Format("{0}(it.{1})", aggregation.ToString().ToUpper(),
                                             valueExpression.Member.Name);
            }

            return(dataSelector);
        }
示例#13
0
        public object Calculate(object RowName, object ColumnName)
        {
            RCAddress address = new RCAddress(RowName, ColumnName);
            if (hValues.ContainsKey(address))
            {

                if (this.aggregationHandler == null)
                {
                    this.aggregationHandler = AggregateFunction.Sum;
                }

                ArrayList set = (ArrayList)hValues[address];

                return this.aggregationHandler(set);
            }

            return DefaultEmptyValue;
        }
示例#14
0
 public static GridColumn[] GetColumnsWithAggregateInt(AggregationFunction aggregation) =>
 new[]
 {
     new GridColumn {
         Name = "Id", Aggregate = aggregation
     },
     new GridColumn {
         Name = "Number"
     },
     new GridColumn {
         Name = "DecimalNumber"
     },
     new GridColumn {
         Name = "Name"
     },
     new GridColumn {
         Name = "Date"
     }
 };
示例#15
0
        private string GetQueryPart(AggregationFunction groupMethod)
        {
            switch (groupMethod)
            {
            case AggregationFunction.Average:
                return("MEAN");

            case AggregationFunction.Sum:
                return("SUM");

            case AggregationFunction.Min:
                return("MIN");

            case AggregationFunction.Max:
                return("MAX");

            default:
                throw new ArgumentException("Invalid group method specified.", nameof(groupMethod));
            }
        }
示例#16
0
 public static GridColumn[] GetColumnsWithAggregateDoubleAndInvalidDate(AggregationFunction aggregation) =>
 new[]
 {
     new GridColumn {
         Name = "Id"
     },
     new GridColumn {
         Name = "Number"
     },
     new GridColumn {
         Name = "DecimalNumber", Aggregate = aggregation, DataType = DataType.Numeric
     },
     new GridColumn {
         Name = "Name"
     },
     new GridColumn
     {
         Name           = "Date",
         FilterArgument = new[] { DateTime.Now.AddDays(1).ToShortDateString() },
         FilterText     = DateTime.Now.AddDays(1).ToShortDateString(),
         FilterOperator = CompareOperators.Equals
     }
 };
示例#17
0
        public string GetAggStr(int columnIndex, AggregationFunction aggFunction)
        {
            switch (aggFunction)
            {
            case AggregationFunction.Count:
                return("COUNT(*)");

            case AggregationFunction.Total:
                return(string.Format("SUM(Column_{0:D})", columnIndex));

            case AggregationFunction.Minimum:
                return(string.Format("MIN(Column_{0:D})", columnIndex));

            case AggregationFunction.Maximum:
                return(string.Format("MAX(Column_{0:D})", columnIndex));

            case AggregationFunction.Median:
            case AggregationFunction.Average:
                return(string.Format("AVG(Column_{0:D})", columnIndex));

            default:
                return(string.Format("Column_{0:D}", columnIndex));
            }
        }
		public AnalysisDataParameterInfo(ITimePeriod time, object value, AggregationFunction function) {
			TimePeriod = time;
			Value = value;
			FunctionName = function;
		} // constructor
示例#19
0
 public AggregatedField( string field, AggregationFunction function )
 {
     Field = field;
      Function = function;
 }
示例#20
0
 /// <summary>
 /// Init PivotTable instance with own agreggation function.
 ///  See also: <seealso cref="AggregationFunction"/>
 /// </summary>
 /// <param name="af"></param>
 public PivotTable(AggregationFunction af)
 {
     dataSets = new AggregationSet();
     // set custom aggregation function if you dont need simple sum
     dataSets.Aggregator = af;
 }
示例#21
0
 public RRAggregateAttribute(AggregationFunction AggregationFunction, String Description)
 {
     this.AggregationFunction = AggregationFunction;
     this.Description = Description;
 }
示例#22
0
 public Aggregation(AggregationFunction function, string x, string y)
 {
     this.function = function;
     this.x        = x;
     this.y        = y;
 }
示例#23
0
        /// <summary>
        /// Creates a single serie chart from a IQueryable
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <typeparam name="R"></typeparam>
        /// <param name="datasource"></param>
        /// <param name="label"></param>
        /// <param name="value"></param>
        /// <param name="serieName"></param>
        /// <param name="aggregation"></param>
        /// <returns></returns>
        public static SingleSerieChartResponse <R> ProvideSingleSerieChartResponse <T, R>(this IQueryable <T> datasource,
                                                                                          Expression <Func <T, string> > label, Expression <Func <T, R> > value, string serieName = null,
                                                                                          AggregationFunction aggregation = AggregationFunction.Sum)
        {
            var labelExpression = label.Body is MemberExpression
                ? (MemberExpression)label.Body
                : ((MemberExpression)((UnaryExpression)label.Body).Operand);

            var valueExpression = value.Body is MemberExpression
                ? (MemberExpression)value.Body
                : ((MemberExpression)((UnaryExpression)value.Body).Operand);

            var dataSelector = GenerateDataSelector(aggregation, valueExpression);

            var data =
                datasource.GroupBy(labelExpression.Member.Name, "it")
                .Select(string.Format("new (it.Key as Label, {0} as Data)", dataSelector));

            return(new SingleSerieChartResponse <R>
            {
                Data = data.Select("Data").Cast <R>().ToArray(),
                SerieName = serieName,
                Labels = data.Select("Label").Cast <string>().ToArray(),
            });
        }
        /// <summary>
        /// Parse a function into aggregation function enum
        /// </summary>
        /// <param name="functionName"></param>
        /// <param name="aggFunc"></param>
        /// <returns></returns>
        public static bool TryParse(string functionName, out AggregationFunction aggFunc)
        {
            string lowerCaseFunctionName = functionName.ToLower();

            switch (lowerCaseFunctionName)
            {
            case "avg":
                aggFunc = AggregationFunction.Avg;
                break;

            case "sum":
                aggFunc = AggregationFunction.Sum;
                break;

            case "count":
                aggFunc = AggregationFunction.Count;
                break;

            case "max":
                aggFunc = AggregationFunction.Max;
                break;

            case "min":
                aggFunc = AggregationFunction.Min;
                break;

            case "first":
                // not supported by cypher but cosmos
                aggFunc = AggregationFunction.First;
                break;

            case "last":
                // not supported by cypher but cosmos
                aggFunc = AggregationFunction.Last;
                break;

            case "percentilecont":
                aggFunc = AggregationFunction.PercentileCont;
                break;

            case "percentiledisc":
                aggFunc = AggregationFunction.PercentileDisc;
                break;

            case "stdev":
                aggFunc = AggregationFunction.StDev;
                break;

            case "stdevp":
                aggFunc = AggregationFunction.StDevP;
                break;

            default:
                // treat it as non-aggregating functions
                aggFunc = AggregationFunction.Invalid;
                return(false);
            }

            // indicating it is an aggregating function
            return(true);
        }
示例#25
0
 public RRSampleAttribute(RRType Type, String Description, AggregationFunction AggregationFunction)
 {
     this.Type                = Type;
     this.Description         = Description;
     this.AggregationFunction = AggregationFunction;
 }
示例#26
0
 public RRAggregateAttribute(AggregationFunction AggregationFunction)
 {
     this.AggregationFunction = AggregationFunction;
     this.Description         = String.Empty;
 }
示例#27
0
 public Aggregation(AggregationFunction function, string name)
 {
     Function = function;
     Name     = name;
 }
示例#28
0
        public static CommonConfiguration GetRecommendationConfiguration()
        {
            SqlServerContext    _client = new SqlServerContext(Mars_Database_Key);
            CommonConfiguration result  = new CommonConfiguration();

            try
            {
                DbCommand command = _client.GetStoredProcCommand("ps_Config_GetCommonConfig");

                using (IDataReader reader = _client.ExecuteReader(command))
                {
                    #region Config_WebSite
                    while (reader.Read())
                    {
                        int webSiteId = SqlDataHelper.GetIntValue("WebSiteId", reader);
                        result.WebSitesValues.Add((WebSites)webSiteId,
                                                  new WebSite
                        {
                            WebSiteId                = (WebSites)webSiteId,
                            Name                     = SqlDataHelper.GetStringValue("Name", reader),
                            SelectionMethodId        = (SelectionMethods)SqlDataHelper.GetIntValue("SelectionMethodId", reader),
                            StrongestInteractionName = SqlDataHelper.GetStringValue("StrongestInteractionName", reader),
                            DownloadFriendsLikes     = SqlDataHelper.GetBoolValue("DownloadFriendsLikes", reader)
                        });
                    }
                    #endregion

                    #region WebSiteAlgorithms
                    reader.NextResult();
                    while (reader.Read())
                    {
                        WebSites webSiteId   = (WebSites)SqlDataHelper.GetIntValue("WebSiteId", reader);
                        int      algorithmId = SqlDataHelper.GetIntValue("AlgorithmId", reader);

                        result.DeclareAlgorithm(webSiteId, algorithmId);
                    }

                    reader.NextResult();
                    #endregion

                    #region AlgorithmGraphActions
                    while (reader.Read())
                    {
                        int algorithmId   = SqlDataHelper.GetIntValue("AlgorithmId", reader);
                        int graphActionId = SqlDataHelper.GetIntValue("GraphActionId", reader);

                        result.DeclareGraphAction(algorithmId, graphActionId);
                    }

                    reader.NextResult();
                    #endregion

                    #region AggregationFunctions
                    List <AggregationFunction> aggregationFunctions = new List <AggregationFunction>();
                    while (reader.Read())
                    {
                        AggregationFunction af = new AggregationFunction();
                        af.Id   = SqlDataHelper.GetIntValue("Id", reader);
                        af.Name = SqlDataHelper.GetStringValue("Name", reader);

                        aggregationFunctions.Add(af);
                    }

                    reader.NextResult();
                    #endregion

                    #region ScoreFunctions
                    List <ScoreFunction> scoreFunctions = new List <ScoreFunction>();
                    while (reader.Read())
                    {
                        ScoreFunction sf = new ScoreFunction();
                        sf.Id   = SqlDataHelper.GetIntValue("Id", reader);
                        sf.Name = SqlDataHelper.GetStringValue("Name", reader);

                        scoreFunctions.Add(sf);
                    }

                    reader.NextResult();
                    #endregion

                    #region ScoreFunctionParameters
                    while (reader.Read())
                    {
                        ScoreFunctionParameter sfp = new ScoreFunctionParameter();
                        sfp.Id         = SqlDataHelper.GetIntValue("Id", reader);
                        sfp.Parameter2 = SqlDataHelper.GetStringValue("Parameter2", reader);
                        sfp.Parameter1 = SqlDataHelper.GetStringValue("Parameter1", reader);
                        sfp.Value      = SqlDataHelper.GetDoubleValue("Value", reader);
                        sfp.WebSiteId  = SqlDataHelper.GetIntValue("WebSiteId", reader);

                        int      graphActionId = SqlDataHelper.GetIntValue("GraphActionId", reader);
                        int      algorithmId   = SqlDataHelper.GetIntValue("AlgorithmId", reader);
                        WebSites webSiteId     = (WebSites)SqlDataHelper.GetIntValue("WebSiteId", reader);

                        result.AddScoreFunctionParameterToGraphAction(webSiteId, algorithmId, graphActionId, sfp);
                    }

                    reader.NextResult();
                    #endregion

                    #region AggregationFunctionParameters
                    while (reader.Read())
                    {
                        AggregationFunctionParameter afp = new AggregationFunctionParameter();
                        afp.Id    = SqlDataHelper.GetIntValue("Id", reader);
                        afp.Name  = SqlDataHelper.GetStringValue("Name", reader);
                        afp.Value = SqlDataHelper.GetDoubleValue("Value", reader);

                        int      algorithmId = SqlDataHelper.GetIntValue("AlgorithmId", reader);
                        WebSites webSiteId   = (WebSites)SqlDataHelper.GetIntValue("WebSiteId", reader);

                        result.AddAggregationFunctionParameterToAlgorithm(webSiteId, algorithmId, afp);
                    }

                    reader.NextResult();
                    List <RecommendationQuery> queries = new List <RecommendationQuery>();
                    while (reader.Read())
                    {
                        RecommendationQuery query = new RecommendationQuery();
                        query.Id           = SqlDataHelper.GetIntValue("Id", reader);
                        query.QueryContent = SqlDataHelper.GetStringValue("Query", reader);

                        queries.Add(query);
                    }

                    reader.NextResult();
                    List <GremlinScript> scripts = new List <GremlinScript>();
                    while (reader.Read())
                    {
                        GremlinScript script = new GremlinScript();
                        script.Id     = SqlDataHelper.GetIntValue("Id", reader);
                        script.Script = SqlDataHelper.GetStringValue("Script", reader);

                        scripts.Add(script);
                    }

                    reader.NextResult();
                    List <MirrorQuery> mirrorQueries = new List <MirrorQuery>();
                    while (reader.Read())
                    {
                        MirrorQuery query = new MirrorQuery();
                        query.Id           = SqlDataHelper.GetIntValue("Id", reader);
                        query.QueryContent = SqlDataHelper.GetStringValue("MirrorQuery", reader);

                        mirrorQueries.Add(query);
                    }

                    reader.NextResult();
                    List <MirrorScripts> mirrorScripts = new List <MirrorScripts>();
                    while (reader.Read())
                    {
                        MirrorScripts script = new MirrorScripts();
                        script.Id           = SqlDataHelper.GetIntValue("Id", reader);
                        script.MirrorScript = SqlDataHelper.GetStringValue("MirrorScript", reader);

                        mirrorScripts.Add(script);
                    }

                    reader.NextResult();
                    #endregion

                    #region GraphActions
                    while (reader.Read())
                    {
                        int    graphActionId = SqlDataHelper.GetIntValue("Id", reader);
                        string name          = SqlDataHelper.GetStringValue("Name", reader);
                        int    expiration    = SqlDataHelper.GetIntValue("Expiration", reader);

                        int?queryId                       = SqlDataHelper.GetNullableInt("QueryId", reader);
                        int?scriptId                      = SqlDataHelper.GetNullableInt("GremlinScriptId", reader);
                        int scoreFunctionId               = SqlDataHelper.GetIntValue("ScoreFunctionId", reader);
                        int?mirrorQueryId                 = SqlDataHelper.GetNullableInt("MirrorQueryId", reader);
                        int?mirrorScriptId                = SqlDataHelper.GetNullableInt("MirrorScriptId", reader);
                        RecommendationQuery query         = queries.Find(q => q.Id == queryId);
                        GremlinScript       script        = scripts.Find(s => s.Id == scriptId);
                        ScoreFunction       scoreFunction = scoreFunctions.Find(sf => sf.Id == scoreFunctionId);
                        MirrorQuery         mirrorQuery   = null;
                        MirrorScripts       mirrorScript  = null;
                        if (mirrorQueryId.HasValue)
                        {
                            mirrorQuery = mirrorQueries.Find(mq => mq.Id == mirrorQueryId.Value);
                        }
                        if (mirrorScriptId.HasValue)
                        {
                            mirrorScript = mirrorScripts.Find(ms => ms.Id == mirrorScriptId.Value);
                        }

                        foreach (GraphAction ga in result.GetGraphActions(graphActionId))
                        {
                            ga.Name          = name;
                            ga.Expiration    = expiration;
                            ga.Query         = query;
                            ga.Script        = script;
                            ga.ScoreFunction = scoreFunction;
                            ga.MirrorQuery   = mirrorQuery;
                            ga.MirrorScript  = mirrorScript;
                        }
                    }

                    reader.NextResult();
                    #endregion

                    #region Algorithms
                    while (reader.Read())
                    {
                        int    algorithmId           = SqlDataHelper.GetIntValue("Id", reader);
                        string name                  = SqlDataHelper.GetStringValue("Name", reader);
                        bool   isStandardQuery       = SqlDataHelper.GetBoolValue("IsStandardQuery", reader);
                        int    aggregationFunctionId = SqlDataHelper.GetIntValue("AggregationFunctionId", reader);
                        AggregationFunction af       = aggregationFunctions.Find(a => a.Id == aggregationFunctionId);

                        foreach (Algorithm algorithm in result.GetAlgorithms(algorithmId))
                        {
                            algorithm.Name                = name;
                            algorithm.IsStandardQuery     = isStandardQuery;
                            algorithm.AggregationFunction = af;
                        }
                    }

                    reader.NextResult();
                    #endregion

                    #region ContentTypeDistribution
                    while (reader.Read())
                    {
                        ContentTypeDistribution distribution = new ContentTypeDistribution();
                        distribution.Id   = SqlDataHelper.GetIntValue("Id", reader);
                        distribution.Name = SqlDataHelper.GetStringValue("Name", reader);

                        result.Distributions[distribution.Id] = distribution;
                    }

                    reader.NextResult();
                    #endregion

                    #region ContentTypeQuota
                    while (reader.Read())
                    {
                        ContentTypeQuota quota = new ContentTypeQuota();
                        quota.Id    = SqlDataHelper.GetIntValue("Id", reader);
                        quota.Name  = SqlDataHelper.GetStringValue("Name", reader);
                        quota.Quota = SqlDataHelper.GetDoubleValue("Quota", reader);

                        int distributionId = SqlDataHelper.GetIntValue("DistributionId", reader);
                        result.AddQuotaToDistribution(distributionId, quota);
                    }

                    reader.NextResult();
                    #endregion

                    #region ContentTypeValues
                    while (reader.Read())
                    {
                        ContentTypeValues value = new ContentTypeValues();
                        value.Id        = SqlDataHelper.GetIntValue("Id", reader);
                        value.Name      = SqlDataHelper.GetStringValue("Name", reader);
                        value.MongoName = SqlDataHelper.GetStringValue("MongoName", reader);
                        value.IsString  = SqlDataHelper.GetBoolValue("IsString", reader);
                        value.Value     = SqlDataHelper.GetStringValue("Value", reader);

                        int quotaId = SqlDataHelper.GetIntValue("QuotaId", reader);
                        result.AddValueToQuota(quotaId, value);
                    }
                    #endregion
                }
            }
            catch (Exception e)
            {
                Logger.Current.Error("GetRecommendationConfiguration", "Error loading configuration", e);
            }
            return(result);
        }