/// <summary>
        /// Generates the 'SELECT' part of an <see cref="SubSonic.Query.Aggregate"/>
        /// </summary>
        /// <param name="aggregate">The aggregate to include in the SELECT clause</param>
        /// <returns>The portion of the SELECT clause represented by this <see cref="SubSonic.Query.Aggregate"/></returns>
        /// <remarks>
        /// The ToString() logic moved from <see cref="SubSonic.Query.Aggregate.ToString"/>, rather than
        /// including it in the Aggregate class itself...
        /// </remarks>
        protected virtual string GenerateAggregateSelect(SubSonic.Query.Aggregate aggregate)
        {
            bool hasAlias = !String.IsNullOrEmpty(aggregate.Alias);

            if (aggregate.AggregateType == AggregateFunction.GroupBy && hasAlias)
            {
                return(String.Format("{0} AS {1}", aggregate.ColumnName, aggregate.Alias));
            }
            if (aggregate.AggregateType == AggregateFunction.GroupBy)
            {
                return(string.Format("{0}", aggregate.ColumnName));
            }
            if (hasAlias)
            {
                return(String.Format("{0}({1}) AS {2}", SubSonic.Query.Aggregate.GetFunctionType(aggregate).ToUpper(),
                                     aggregate.ColumnName, aggregate.Alias));
            }

            return(String.Format("{0}({1})", SubSonic.Query.Aggregate.GetFunctionType(aggregate).ToUpper(), aggregate.ColumnName));
        }
示例#2
0
        /// <summary>
        /// Groups the by.
        /// </summary>
        /// <param name="columnName">Name of the column.</param>
        /// <param name="alias">The alias.</param>
        /// <returns></returns>
        public static Aggregate GroupBy(string columnName, string alias)
        {
            Aggregate agg = new Aggregate(columnName, alias, AggregateFunction.GroupBy);

            return(agg);
        }
示例#3
0
        protected override string GenerateAggregateSelect(Aggregate aggregate)
        {
            bool hasAlias = !String.IsNullOrEmpty(aggregate.Alias);

            if(aggregate.AggregateType == AggregateFunction.GroupBy && hasAlias)
                return String.Format("`{0}` AS `{1}`", aggregate.ColumnName, aggregate.Alias);
            if(aggregate.AggregateType == AggregateFunction.GroupBy)
                return string.Format("`{0}`", aggregate.ColumnName);
            if(hasAlias)
            {
                return String.Format("{0}(`{1}`) AS `{2}`", Aggregate.GetFunctionType(aggregate).ToUpper(),
                    aggregate.ColumnName, aggregate.Alias);
            }

            return String.Format("{0}(`{1}`)", Aggregate.GetFunctionType(aggregate).ToUpper(), aggregate.ColumnName);
        }
示例#4
0
 /// <summary>
 /// Counts the specified column name.
 /// </summary>
 /// <param name="columnName">Name of the column.</param>
 /// <param name="alias">The alias.</param>
 /// <returns></returns>
 public static Aggregate Count(string columnName, string alias)
 {
     Aggregate agg = new Aggregate(columnName, alias, AggregateFunction.Count);
     return agg;
 }
示例#5
0
 /// <summary>
 /// Counts the specified col.
 /// </summary>
 /// <param name="col">The col.</param>
 /// <returns></returns>
 public static Aggregate Count(IColumn col)
 {
     Aggregate agg = new Aggregate(col, AggregateFunction.Count);
     return agg;
 }
示例#6
0
 /// <summary>
 /// Standards the deviation.
 /// </summary>
 /// <param name="col">The col.</param>
 /// <returns></returns>
 public static Aggregate StandardDeviation(IColumn col)
 {
     Aggregate agg = new Aggregate(col, AggregateFunction.StDev);
     return agg;
 }
示例#7
0
 /// <summary>
 /// Variances the specified col.
 /// </summary>
 /// <param name="col">The col.</param>
 /// <returns></returns>
 public static Aggregate Variance(IColumn col)
 {
     Aggregate agg = new Aggregate(col, AggregateFunction.Var);
     return agg;
 }
示例#8
0
 /// <summary>
 /// Mins the specified column name.
 /// </summary>
 /// <param name="columnName">Name of the column.</param>
 /// <returns></returns>
 public static Aggregate Min(string columnName)
 {
     Aggregate agg = new Aggregate(columnName, AggregateFunction.Min);
     return agg;
 }
示例#9
0
        /// <summary>
        /// Standards the deviation.
        /// </summary>
        /// <param name="col">The col.</param>
        /// <returns></returns>
        public static Aggregate StandardDeviation(IColumn col)
        {
            Aggregate agg = new Aggregate(col, AggregateFunction.StDev);

            return(agg);
        }
示例#10
0
        /// <summary>
        /// Variances the specified column name.
        /// </summary>
        /// <param name="columnName">Name of the column.</param>
        /// <param name="alias">The alias.</param>
        /// <returns></returns>
        public static Aggregate Variance(string columnName, string alias)
        {
            Aggregate agg = new Aggregate(columnName, alias, AggregateFunction.Var);

            return(agg);
        }
示例#11
0
        /// <summary>
        /// Variances the specified col.
        /// </summary>
        /// <param name="col">The col.</param>
        /// <returns></returns>
        public static Aggregate Variance(IColumn col)
        {
            Aggregate agg = new Aggregate(col, AggregateFunction.Var);

            return(agg);
        }
示例#12
0
        /// <summary>
        /// Mins the specified col.
        /// </summary>
        /// <param name="col">The col.</param>
        /// <param name="alias">The alias.</param>
        /// <returns></returns>
        public static Aggregate Min(IColumn col, string alias)
        {
            Aggregate agg = new Aggregate(col, alias, AggregateFunction.Min);

            return(agg);
        }
示例#13
0
        /// <summary>
        /// Mins the specified column name.
        /// </summary>
        /// <param name="columnName">Name of the column.</param>
        /// <returns></returns>
        public static Aggregate Min(string columnName)
        {
            Aggregate agg = new Aggregate(columnName, AggregateFunction.Min);

            return(agg);
        }
示例#14
0
        /// <summary>
        /// Mins the specified col.
        /// </summary>
        /// <param name="col">The col.</param>
        /// <returns></returns>
        public static Aggregate Min(IColumn col)
        {
            Aggregate agg = new Aggregate(col, AggregateFunction.Min);

            return(agg);
        }
示例#15
0
 /// <summary>
 /// Avgs the specified col.
 /// </summary>
 /// <param name="col">The col.</param>
 /// <returns></returns>
 public static Aggregate Avg(IColumn col)
 {
     Aggregate agg = new Aggregate(col, AggregateFunction.Avg);
     return agg;
 }
示例#16
0
 /// <summary>
 /// Mins the specified col.
 /// </summary>
 /// <param name="col">The col.</param>
 /// <returns></returns>
 public static Aggregate Min(IColumn col)
 {
     Aggregate agg = new Aggregate(col, AggregateFunction.Min);
     return agg;
 }
示例#17
0
        /// <summary>
        /// Standards the deviation.
        /// </summary>
        /// <param name="columnName">Name of the column.</param>
        /// <param name="alias">The alias.</param>
        /// <returns></returns>
        public static Aggregate StandardDeviation(string columnName, string alias)
        {
            Aggregate agg = new Aggregate(columnName, alias, AggregateFunction.StDev);

            return(agg);
        }
示例#18
0
 /// <summary>
 /// Mins the specified col.
 /// </summary>
 /// <param name="col">The col.</param>
 /// <param name="alias">The alias.</param>
 /// <returns></returns>
 public static Aggregate Min(IColumn col, string alias)
 {
     Aggregate agg = new Aggregate(col, alias, AggregateFunction.Min);
     return agg;
 }
示例#19
0
        /// <summary>
        /// Counts the specified col.
        /// </summary>
        /// <param name="col">The col.</param>
        /// <returns></returns>
        public static Aggregate Count(IColumn col)
        {
            Aggregate agg = new Aggregate(col, AggregateFunction.Count);

            return(agg);
        }
示例#20
0
 /// <summary>
 /// Variances the specified column name.
 /// </summary>
 /// <param name="columnName">Name of the column.</param>
 /// <param name="alias">The alias.</param>
 /// <returns></returns>
 public static Aggregate Variance(string columnName, string alias)
 {
     Aggregate agg = new Aggregate(columnName, alias, AggregateFunction.Var);
     return agg;
 }
示例#21
0
 /// <summary>
 /// Gets the type of the function.
 /// </summary>
 /// <param name="agg">The agg.</param>
 /// <returns></returns>
 public static string GetFunctionType(Aggregate agg)
 {
     return(Enum.GetName(typeof(AggregateFunction), agg.AggregateType));
 }
示例#22
0
 /// <summary>
 /// Standards the deviation.
 /// </summary>
 /// <param name="columnName">Name of the column.</param>
 /// <param name="alias">The alias.</param>
 /// <returns></returns>
 public static Aggregate StandardDeviation(string columnName, string alias)
 {
     Aggregate agg = new Aggregate(columnName, alias, AggregateFunction.StDev);
     return agg;
 }
示例#23
0
        /// <summary>
        /// Counts the specified column name.
        /// </summary>
        /// <param name="columnName">Name of the column.</param>
        /// <param name="alias">The alias.</param>
        /// <returns></returns>
        public static Aggregate Count(string columnName, string alias)
        {
            Aggregate agg = new Aggregate(columnName, alias, AggregateFunction.Count);

            return(agg);
        }
示例#24
0
 /// <summary>
 /// Gets the type of the function.
 /// </summary>
 /// <param name="agg">The agg.</param>
 /// <returns></returns>
 public static string GetFunctionType(Aggregate agg)
 {
     return Enum.GetName(typeof(AggregateFunction), agg.AggregateType);
 }
示例#25
0
        /// <summary>
        /// Sums the specified col.
        /// </summary>
        /// <param name="col">The col.</param>
        /// <returns></returns>
        public static Aggregate Sum(IColumn col)
        {
            Aggregate agg = new Aggregate(col, AggregateFunction.Sum);

            return(agg);
        }
示例#26
0
 /// <summary>
 /// Sums the specified col.
 /// </summary>
 /// <param name="col">The col.</param>
 /// <returns></returns>
 public static Aggregate Sum(IColumn col)
 {
     Aggregate agg = new Aggregate(col, AggregateFunction.Sum);
     return agg;
 }
示例#27
0
 /// <summary>
 /// Groups the by.
 /// </summary>
 /// <param name="col">The col.</param>
 /// <returns></returns>
 public static Aggregate GroupBy(IColumn col)
 {
     Aggregate agg = new Aggregate(col, AggregateFunction.GroupBy);
     return agg;
 }
示例#28
0
 /// <summary>
 /// Groups the by.
 /// </summary>
 /// <param name="columnName">Name of the column.</param>
 /// <param name="alias">The alias.</param>
 /// <returns></returns>
 public static Aggregate GroupBy(string columnName, string alias)
 {
     Aggregate agg = new Aggregate(columnName, alias, AggregateFunction.GroupBy);
     return agg;
 }
示例#29
0
        /// <summary>
        /// Groups the by.
        /// </summary>
        /// <param name="col">The col.</param>
        /// <returns></returns>
        public static Aggregate GroupBy(IColumn col)
        {
            Aggregate agg = new Aggregate(col, AggregateFunction.GroupBy);

            return(agg);
        }