示例#1
0
        /// <summary>
        /// Generates the 'SELECT' part of an <see cref="SubSonic.Oracle.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.Oracle.Query.Aggregate"/></returns>
        /// <remarks>
        /// The ToString() logic moved from <see cref="SubSonic.Oracle.Query.Aggregate.ToString"/>, rather than
        /// including it in the Aggregate class itself...
        /// </remarks>
        protected virtual string GenerateAggregateSelect(SubSonic.Oracle.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.Oracle.Query.Aggregate.GetFunctionType(aggregate).ToUpper(),
                                     aggregate.ColumnName, aggregate.Alias));
            }

            return(String.Format("{0}({1})", SubSonic.Oracle.Query.Aggregate.GetFunctionType(aggregate).ToUpper(), aggregate.ColumnName));
        }
示例#2
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);
        }
示例#3
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);
        }
示例#4
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);
        }
示例#5
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));
 }
示例#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>
        /// 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);
        }
示例#8
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);
        }
示例#9
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);
        }
示例#10
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);
        }
示例#11
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);
        }
示例#12
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);
        }
示例#13
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);
        }
示例#14
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);
        }